@legendapp/list 3.0.0-beta.33 → 3.0.0-beta.35

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/reanimated.d.ts CHANGED
@@ -228,6 +228,11 @@ interface LegendListSpecificProps<ItemT, TItemType extends string | undefined> {
228
228
  * - true enables both behaviors; false disables both.
229
229
  */
230
230
  maintainVisibleContentPosition?: boolean | MaintainVisibleContentPositionConfig<ItemT>;
231
+ /**
232
+ * Web only: when true, listens to window/body scrolling instead of rendering a scrollable list container.
233
+ * @default false
234
+ */
235
+ useWindowScroll?: boolean;
231
236
  /**
232
237
  * Number of columns to render items in.
233
238
  * @default 1
@@ -416,7 +421,7 @@ type LegendListState = {
416
421
  listen: <T extends LegendListListenerType>(listenerType: T, callback: (value: ListenerTypeValueMap[T]) => void) => () => void;
417
422
  listenToPosition: (key: string, callback: (value: number) => void) => () => void;
418
423
  positionAtIndex: (index: number) => number;
419
- positions: Map<string, number>;
424
+ positionByKey: (key: string) => number | undefined;
420
425
  scroll: number;
421
426
  scrollLength: number;
422
427
  scrollVelocity: number;
@@ -455,7 +460,7 @@ type LegendListRef$1 = {
455
460
  scrollIndexIntoView(params: {
456
461
  animated?: boolean | undefined;
457
462
  index: number;
458
- }): void;
463
+ }): Promise<void>;
459
464
  /**
460
465
  * Scrolls a specific index into view.
461
466
  * @param params - Parameters for scrolling.
@@ -465,7 +470,7 @@ type LegendListRef$1 = {
465
470
  scrollItemIntoView(params: {
466
471
  animated?: boolean | undefined;
467
472
  item: any;
468
- }): void;
473
+ }): Promise<void>;
469
474
  /**
470
475
  * Scrolls to the end of the list.
471
476
  * @param options - Options for scrolling.
@@ -475,7 +480,7 @@ type LegendListRef$1 = {
475
480
  scrollToEnd(options?: {
476
481
  animated?: boolean | undefined;
477
482
  viewOffset?: number | undefined;
478
- }): void;
483
+ }): Promise<void>;
479
484
  /**
480
485
  * Scrolls to a specific index in the list.
481
486
  * @param params - Parameters for scrolling.
@@ -489,7 +494,7 @@ type LegendListRef$1 = {
489
494
  index: number;
490
495
  viewOffset?: number | undefined;
491
496
  viewPosition?: number | undefined;
492
- }): void;
497
+ }): Promise<void>;
493
498
  /**
494
499
  * Scrolls to a specific item in the list.
495
500
  * @param params - Parameters for scrolling.
@@ -503,7 +508,7 @@ type LegendListRef$1 = {
503
508
  item: any;
504
509
  viewOffset?: number | undefined;
505
510
  viewPosition?: number | undefined;
506
- }): void;
511
+ }): Promise<void>;
507
512
  /**
508
513
  * Scrolls to a specific offset in pixels.
509
514
  * @param params - Parameters for scrolling.
@@ -513,7 +518,7 @@ type LegendListRef$1 = {
513
518
  scrollToOffset(params: {
514
519
  offset: number;
515
520
  animated?: boolean | undefined;
516
- }): void;
521
+ }): Promise<void>;
517
522
  /**
518
523
  * Sets or adds to the offset of the visible content anchor.
519
524
  * @param value - The offset to set or add.
@@ -595,6 +600,11 @@ type KeysToOmit = "animatedProps" | "getEstimatedItemSize" | "getFixedItemSize"
595
600
  type PropsBase<ItemT> = LegendListPropsBase<ItemT, ComponentProps<typeof Reanimated.ScrollView>>;
596
601
  interface AnimatedLegendListPropsBase<ItemT> extends Omit<PropsBase<ItemT>, KeysToOmit> {
597
602
  refScrollView?: React$1.Ref<Reanimated.ScrollView>;
603
+ /**
604
+ * Reanimated layout transition applied to each item container position view.
605
+ * Example: `LinearTransition.duration(280)`.
606
+ */
607
+ itemLayoutAnimation?: ComponentProps<typeof Reanimated.View>["layout"];
598
608
  }
599
609
  type OtherAnimatedLegendListProps<ItemT> = Pick<PropsBase<ItemT>, KeysToOmit>;
600
610
  type AnimatedLegendListProps<ItemT> = Omit<AnimatedLegendListPropsBase<ItemT>, "refLegendList" | "ref"> & OtherAnimatedLegendListProps<ItemT>;
package/reanimated.js CHANGED
@@ -171,10 +171,19 @@ var ReanimatedPositionViewSticky = typedMemo(function ReanimatedPositionViewStic
171
171
  );
172
172
  return /* @__PURE__ */ React3__namespace.createElement(Reanimated__default.default.View, { ref: refView, style: viewStyle, ...rest }, /* @__PURE__ */ React3__namespace.createElement(StickyOverlay, { stickyHeaderConfig }), children);
173
173
  });
174
+ var ReanimatedPositionView = typedMemo(function ReanimatedPositionViewComponent(props) {
175
+ const { id, horizontal, style, refView, children, layoutTransition, ...rest } = props;
176
+ const [positionValue = POSITION_OUT_OF_VIEW] = useArr$([`containerPosition${id}`]);
177
+ const viewStyle = React3__namespace.useMemo(
178
+ () => [style, horizontal ? { left: positionValue } : { top: positionValue }],
179
+ [horizontal, positionValue, style]
180
+ );
181
+ return /* @__PURE__ */ React3__namespace.createElement(Reanimated__default.default.View, { layout: layoutTransition, ref: refView, style: viewStyle, ...rest }, children);
182
+ });
174
183
  var LegendListForwardedRef = typedMemo(
175
184
  // biome-ignore lint/nursery/noShadow: const function name shadowing is intentional
176
185
  React3__namespace.forwardRef(function LegendListForwardedRef2(props, ref) {
177
- const { refLegendList, ...rest } = props;
186
+ const { itemLayoutAnimation, refLegendList, ...rest } = props;
178
187
  const refFn = React3.useCallback(
179
188
  (r) => {
180
189
  refLegendList(r);
@@ -203,11 +212,25 @@ var LegendListForwardedRef = typedMemo(
203
212
  },
204
213
  [stickyScrollOffset]
205
214
  );
206
- const legendListProps = shouldUseReanimatedScrollView ? {
215
+ const itemLayoutAnimationRef = React3__namespace.useRef(itemLayoutAnimation);
216
+ itemLayoutAnimationRef.current = itemLayoutAnimation;
217
+ const hasItemLayoutAnimation = !!itemLayoutAnimation;
218
+ const positionComponentInternal = React3__namespace.useMemo(() => {
219
+ if (!hasItemLayoutAnimation) {
220
+ return void 0;
221
+ }
222
+ return function PositionComponent(positionProps) {
223
+ return /* @__PURE__ */ React3__namespace.createElement(ReanimatedPositionView, { ...positionProps, layoutTransition: itemLayoutAnimationRef.current });
224
+ };
225
+ }, [hasItemLayoutAnimation]);
226
+ const legendListProps = {
207
227
  ...rest,
208
- renderScrollComponent: renderReanimatedScrollComponent,
209
- stickyPositionComponentInternal
210
- } : rest;
228
+ positionComponentInternal,
229
+ ...shouldUseReanimatedScrollView ? {
230
+ renderScrollComponent: renderReanimatedScrollComponent,
231
+ stickyPositionComponentInternal
232
+ } : {}
233
+ };
211
234
  return /* @__PURE__ */ React3__namespace.createElement(reactNative$1.LegendList, { ref: refFn, refScrollView: ref, ...legendListProps });
212
235
  })
213
236
  );
package/reanimated.mjs CHANGED
@@ -147,10 +147,19 @@ var ReanimatedPositionViewSticky = typedMemo(function ReanimatedPositionViewStic
147
147
  );
148
148
  return /* @__PURE__ */ React3.createElement(Reanimated.View, { ref: refView, style: viewStyle, ...rest }, /* @__PURE__ */ React3.createElement(StickyOverlay, { stickyHeaderConfig }), children);
149
149
  });
150
+ var ReanimatedPositionView = typedMemo(function ReanimatedPositionViewComponent(props) {
151
+ const { id, horizontal, style, refView, children, layoutTransition, ...rest } = props;
152
+ const [positionValue = POSITION_OUT_OF_VIEW] = useArr$([`containerPosition${id}`]);
153
+ const viewStyle = React3.useMemo(
154
+ () => [style, horizontal ? { left: positionValue } : { top: positionValue }],
155
+ [horizontal, positionValue, style]
156
+ );
157
+ return /* @__PURE__ */ React3.createElement(Reanimated.View, { layout: layoutTransition, ref: refView, style: viewStyle, ...rest }, children);
158
+ });
150
159
  var LegendListForwardedRef = typedMemo(
151
160
  // biome-ignore lint/nursery/noShadow: const function name shadowing is intentional
152
161
  React3.forwardRef(function LegendListForwardedRef2(props, ref) {
153
- const { refLegendList, ...rest } = props;
162
+ const { itemLayoutAnimation, refLegendList, ...rest } = props;
154
163
  const refFn = useCallback(
155
164
  (r) => {
156
165
  refLegendList(r);
@@ -179,11 +188,25 @@ var LegendListForwardedRef = typedMemo(
179
188
  },
180
189
  [stickyScrollOffset]
181
190
  );
182
- const legendListProps = shouldUseReanimatedScrollView ? {
191
+ const itemLayoutAnimationRef = React3.useRef(itemLayoutAnimation);
192
+ itemLayoutAnimationRef.current = itemLayoutAnimation;
193
+ const hasItemLayoutAnimation = !!itemLayoutAnimation;
194
+ const positionComponentInternal = React3.useMemo(() => {
195
+ if (!hasItemLayoutAnimation) {
196
+ return void 0;
197
+ }
198
+ return function PositionComponent(positionProps) {
199
+ return /* @__PURE__ */ React3.createElement(ReanimatedPositionView, { ...positionProps, layoutTransition: itemLayoutAnimationRef.current });
200
+ };
201
+ }, [hasItemLayoutAnimation]);
202
+ const legendListProps = {
183
203
  ...rest,
184
- renderScrollComponent: renderReanimatedScrollComponent,
185
- stickyPositionComponentInternal
186
- } : rest;
204
+ positionComponentInternal,
205
+ ...shouldUseReanimatedScrollView ? {
206
+ renderScrollComponent: renderReanimatedScrollComponent,
207
+ stickyPositionComponentInternal
208
+ } : {}
209
+ };
187
210
  return /* @__PURE__ */ React3.createElement(LegendList, { ref: refFn, refScrollView: ref, ...legendListProps });
188
211
  })
189
212
  );
package/section-list.d.ts CHANGED
@@ -284,6 +284,11 @@ interface LegendListSpecificProps<ItemT, TItemType extends string | undefined> {
284
284
  * - true enables both behaviors; false disables both.
285
285
  */
286
286
  maintainVisibleContentPosition?: boolean | MaintainVisibleContentPositionConfig<ItemT>;
287
+ /**
288
+ * Web only: when true, listens to window/body scrolling instead of rendering a scrollable list container.
289
+ * @default false
290
+ */
291
+ useWindowScroll?: boolean;
287
292
  /**
288
293
  * Number of columns to render items in.
289
294
  * @default 1
@@ -472,7 +477,7 @@ type LegendListState = {
472
477
  listen: <T extends LegendListListenerType>(listenerType: T, callback: (value: ListenerTypeValueMap[T]) => void) => () => void;
473
478
  listenToPosition: (key: string, callback: (value: number) => void) => () => void;
474
479
  positionAtIndex: (index: number) => number;
475
- positions: Map<string, number>;
480
+ positionByKey: (key: string) => number | undefined;
476
481
  scroll: number;
477
482
  scrollLength: number;
478
483
  scrollVelocity: number;
@@ -511,7 +516,7 @@ type LegendListRef$1 = {
511
516
  scrollIndexIntoView(params: {
512
517
  animated?: boolean | undefined;
513
518
  index: number;
514
- }): void;
519
+ }): Promise<void>;
515
520
  /**
516
521
  * Scrolls a specific index into view.
517
522
  * @param params - Parameters for scrolling.
@@ -521,7 +526,7 @@ type LegendListRef$1 = {
521
526
  scrollItemIntoView(params: {
522
527
  animated?: boolean | undefined;
523
528
  item: any;
524
- }): void;
529
+ }): Promise<void>;
525
530
  /**
526
531
  * Scrolls to the end of the list.
527
532
  * @param options - Options for scrolling.
@@ -531,7 +536,7 @@ type LegendListRef$1 = {
531
536
  scrollToEnd(options?: {
532
537
  animated?: boolean | undefined;
533
538
  viewOffset?: number | undefined;
534
- }): void;
539
+ }): Promise<void>;
535
540
  /**
536
541
  * Scrolls to a specific index in the list.
537
542
  * @param params - Parameters for scrolling.
@@ -545,7 +550,7 @@ type LegendListRef$1 = {
545
550
  index: number;
546
551
  viewOffset?: number | undefined;
547
552
  viewPosition?: number | undefined;
548
- }): void;
553
+ }): Promise<void>;
549
554
  /**
550
555
  * Scrolls to a specific item in the list.
551
556
  * @param params - Parameters for scrolling.
@@ -559,7 +564,7 @@ type LegendListRef$1 = {
559
564
  item: any;
560
565
  viewOffset?: number | undefined;
561
566
  viewPosition?: number | undefined;
562
- }): void;
567
+ }): Promise<void>;
563
568
  /**
564
569
  * Scrolls to a specific offset in pixels.
565
570
  * @param params - Parameters for scrolling.
@@ -569,7 +574,7 @@ type LegendListRef$1 = {
569
574
  scrollToOffset(params: {
570
575
  offset: number;
571
576
  animated?: boolean | undefined;
572
- }): void;
577
+ }): Promise<void>;
573
578
  /**
574
579
  * Sets or adds to the offset of the visible content anchor.
575
580
  * @param value - The offset to set or add.