react-native-terra-ui 0.4.1 → 0.5.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.
Files changed (48) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/lib/module/components/header/parts/HeaderGradientOverlay.js +1 -1
  3. package/lib/module/components/header/parts/HeaderGradientOverlay.js.map +1 -1
  4. package/lib/module/components/screen/Screen.js +1 -4
  5. package/lib/module/components/screen/Screen.js.map +1 -1
  6. package/lib/module/components/screen/ScreenFlatList.js +12 -0
  7. package/lib/module/components/screen/ScreenFlatList.js.map +1 -1
  8. package/lib/module/components/screen/ScreenList.js +2 -2
  9. package/lib/module/components/screen/ScreenList.js.map +1 -1
  10. package/lib/module/components/screen/index.js +0 -1
  11. package/lib/module/components/screen/index.js.map +1 -1
  12. package/lib/module/components/toast/Toast.js +2 -2
  13. package/lib/module/components/toolbar/Toolbar.js +3 -1
  14. package/lib/module/components/toolbar/Toolbar.js.map +1 -1
  15. package/lib/module/theme/tokens/primitives.js +8 -3
  16. package/lib/module/theme/tokens/primitives.js.map +1 -1
  17. package/lib/typescript/src/components/screen/Screen.d.ts +1 -2
  18. package/lib/typescript/src/components/screen/Screen.d.ts.map +1 -1
  19. package/lib/typescript/src/components/screen/ScreenContext.d.ts +2 -2
  20. package/lib/typescript/src/components/screen/ScreenFlatList.d.ts +11 -0
  21. package/lib/typescript/src/components/screen/ScreenFlatList.d.ts.map +1 -1
  22. package/lib/typescript/src/components/screen/ScreenList.d.ts +3 -2
  23. package/lib/typescript/src/components/screen/ScreenList.d.ts.map +1 -1
  24. package/lib/typescript/src/components/screen/index.d.ts +0 -2
  25. package/lib/typescript/src/components/screen/index.d.ts.map +1 -1
  26. package/lib/typescript/src/components/screen/types.d.ts +2 -3
  27. package/lib/typescript/src/components/screen/types.d.ts.map +1 -1
  28. package/lib/typescript/src/theme/tokens/primitives.d.ts +5 -0
  29. package/lib/typescript/src/theme/tokens/primitives.d.ts.map +1 -1
  30. package/lib/typescript/src/theme/types.d.ts +1 -1
  31. package/lib/typescript/src/theme/types.d.ts.map +1 -1
  32. package/package.json +2 -4
  33. package/src/components/header/parts/HeaderGradientOverlay.tsx +1 -1
  34. package/src/components/screen/Screen.tsx +2 -5
  35. package/src/components/screen/ScreenContext.tsx +2 -2
  36. package/src/components/screen/ScreenFlatList.tsx +11 -0
  37. package/src/components/screen/ScreenList.tsx +5 -4
  38. package/src/components/screen/index.ts +0 -2
  39. package/src/components/screen/types.ts +2 -3
  40. package/src/components/toast/Toast.tsx +2 -2
  41. package/src/components/toolbar/Toolbar.tsx +2 -0
  42. package/src/theme/tokens/primitives.ts +9 -3
  43. package/src/theme/types.ts +1 -1
  44. package/lib/module/components/screen/ScreenFlashList.js +0 -166
  45. package/lib/module/components/screen/ScreenFlashList.js.map +0 -1
  46. package/lib/typescript/src/components/screen/ScreenFlashList.d.ts +0 -43
  47. package/lib/typescript/src/components/screen/ScreenFlashList.d.ts.map +0 -1
  48. package/src/components/screen/ScreenFlashList.tsx +0 -216
@@ -20,7 +20,7 @@ export function HeaderGradientOverlay({ color }: HeaderGradientOverlayProps) {
20
20
  <Defs>
21
21
  <SvgLinearGradient id={gradientId} x1="0" y1="0" x2="0" y2="1">
22
22
  <Stop offset="0" stopColor={color} stopOpacity="1" />
23
- <Stop offset="1" stopColor={color} stopOpacity="0.9" />
23
+ <Stop offset="1" stopColor={color} stopOpacity="0.86" />
24
24
  </SvgLinearGradient>
25
25
  </Defs>
26
26
  <Rect width="100%" height="100%" fill={`url(#${gradientId})`} />
@@ -17,7 +17,6 @@ import type { ColorToken } from '#theme/types';
17
17
  import { resolveThemeColor } from '#utils/resolve-theme-color';
18
18
  import { PortalProvider } from '../portal';
19
19
  import { ScreenScrollProvider } from './ScreenContext';
20
- import { ScreenFlashList } from './ScreenFlashList';
21
20
  import { ScreenFlatList } from './ScreenFlatList';
22
21
  import { ScreenList } from './ScreenList';
23
22
  import { ScreenScrollView } from './ScreenScrollView';
@@ -95,16 +94,15 @@ type ScreenComponent = ReturnType<
95
94
  > & {
96
95
  Header: typeof ScreenHeader;
97
96
  ScrollView: typeof ScreenScrollView;
97
+ /** @deprecated Use {@link ScreenList} (`Screen.List`) instead. */
98
98
  FlatList: typeof ScreenFlatList;
99
- FlashList: typeof ScreenFlashList;
100
99
  List: typeof ScreenList;
101
100
  };
102
101
 
103
102
  /**
104
103
  * Themed page container: solid themed background, safe-area handling, and a
105
104
  * shared scroll context for headers. Pair with `Screen.ScrollView` /
106
- * `Screen.List` (or `Screen.FlatList` / `Screen.FlashList` directly) and a
107
- * `Header.LargeTitle` / `Header.Title`.
105
+ * `Screen.List` and a `Header.LargeTitle` / `Header.Title`.
108
106
  *
109
107
  * @example
110
108
  * ```tsx
@@ -141,7 +139,6 @@ const ScreenBase = forwardRef<ComponentRef<typeof View>, ScreenProps>(
141
139
  ScreenBase.Header = ScreenHeader;
142
140
  ScreenBase.ScrollView = ScreenScrollView;
143
141
  ScreenBase.FlatList = ScreenFlatList;
144
- ScreenBase.FlashList = ScreenFlashList;
145
142
  ScreenBase.List = ScreenList;
146
143
 
147
144
  export const Screen = ScreenBase;
@@ -26,8 +26,8 @@ export const SCREEN_HEADER_PORTAL_HOST = 'screen-header';
26
26
  export interface ScreenContextValue {
27
27
  /**
28
28
  * Which axes scroll containers pad with `layout.screen.margin`.
29
- * Overridable per `Screen.ScrollView` / `Screen.FlatList` /
30
- * `Screen.FlashList` via their own `margins` prop.
29
+ * Overridable per `Screen.ScrollView` / `Screen.FlatList` / `Screen.List`
30
+ * via their own `margins` prop.
31
31
  */
32
32
  margins: ScreenMargins;
33
33
  /** Whether a `Screen.Header` is present. Used by scroll containers to add top inset. */
@@ -20,6 +20,12 @@ import { SCREEN_HEADER_PORTAL_HOST, useScreen } from './ScreenContext';
20
20
  import type { ScreenMargins, ScreenScrollableProps } from './types';
21
21
  import { hasXMargin, hasYMargin, renderListHeader } from './utils';
22
22
 
23
+ /**
24
+ * @deprecated Use {@link ScreenListProps} (`Screen.List`) instead —
25
+ * `Screen.List` renders `FlatList` by default and binds the screen's shared
26
+ * scroll ref exactly as `Screen.FlatList` does, but also lets a screen swap in
27
+ * any other FlatList-shaped list (e.g. `FlashList`) via its `as` prop.
28
+ */
23
29
  export interface ScreenFlatListProps<T>
24
30
  extends Omit<FlatListProps<T>, 'CellRendererComponent' | 'horizontal'>,
25
31
  ScreenScrollableProps {
@@ -40,6 +46,11 @@ export interface ScreenFlatListProps<T>
40
46
  * `horizontal` with `Screen.ScrollView`, so a screen can swap one container for
41
47
  * another without relearning its API.
42
48
  *
49
+ * @deprecated Use {@link ScreenList} (`Screen.List`) instead — it renders
50
+ * `FlatList` by default and behaves identically, but also accepts an `as`
51
+ * prop for swapping in another list implementation later without changing
52
+ * the surrounding API.
53
+ *
43
54
  * @example
44
55
  * ```tsx
45
56
  * <Screen.FlatList data={items} renderItem={({ item }) => <Row item={item} />} />
@@ -64,8 +64,9 @@ export type ScreenListProps<
64
64
  *
65
65
  * Only the default `FlatList` binds the screen's shared imperative
66
66
  * scroll ref — a custom `as` is responsible for its own ref if it needs
67
- * one, since not every list exposes a Reanimated-compatible ref (this is
68
- * why `Screen.FlashList` doesn't bind it either).
67
+ * one, since not every list exposes a Reanimated-compatible ref (e.g.
68
+ * `FlashList`'s ref exposes a different, non Reanimated-compatible
69
+ * imperative API).
69
70
  */
70
71
  as?: As;
71
72
  data?: readonly T[] | null;
@@ -133,8 +134,8 @@ export function ScreenList<
133
134
 
134
135
  // `Animated.createAnimatedComponent` should only run once per component,
135
136
  // not on every render — `as` is arbitrary here (not a fixed module-scope
136
- // reference like `Screen.FlatList`/`Screen.FlashList` use), so it's
137
- // memoized on the resolved component instead of hoisted to module scope.
137
+ // reference like `Screen.FlatList` uses), so it's memoized on the resolved
138
+ // component instead of hoisted to module scope.
138
139
  const AnimatedComponent = useMemo(
139
140
  () => Animated.createAnimatedComponent(Component),
140
141
  [Component]
@@ -2,8 +2,6 @@ export type { ScreenHeaderProps, ScreenProps } from './Screen';
2
2
  export { Screen } from './Screen';
3
3
  export type { ScreenContextValue } from './ScreenContext';
4
4
  export { useScreen } from './ScreenContext';
5
- export type { ScreenFlashListProps } from './ScreenFlashList';
6
- export { ScreenFlashList } from './ScreenFlashList';
7
5
  export type { ScreenFlatListProps } from './ScreenFlatList';
8
6
  export { ScreenFlatList } from './ScreenFlatList';
9
7
  export type { ScreenListProps } from './ScreenList';
@@ -11,9 +11,8 @@ import type { ReactNode } from 'react';
11
11
  export type ScreenMargins = 'all' | 'x' | 'y' | 'none';
12
12
 
13
13
  /**
14
- * Props shared by `Screen.ScrollView`, `Screen.FlatList` and
15
- * `Screen.FlashList`, so a screen can swap one container for another without
16
- * relearning its API.
14
+ * Props shared by `Screen.ScrollView`, `Screen.FlatList` and `Screen.List`, so
15
+ * a screen can swap one container for another without relearning its API.
17
16
  */
18
17
  export interface ScreenScrollableProps {
19
18
  /** Lay content out along the x axis. Defaults to `false`. */
@@ -150,7 +150,7 @@ const ToastRoot = forwardRef<ComponentRef<typeof View>, ToastProps>(
150
150
  p="4"
151
151
  row
152
152
  align="center"
153
- gap="3"
153
+ gap="2"
154
154
  accessibilityRole={accessibilityRole}
155
155
  accessibilityLiveRegion="polite"
156
156
  borderWidth="hairline"
@@ -415,7 +415,7 @@ export function DefaultToast({
415
415
  {shouldRenderIcon ? (
416
416
  <Box alignSelf="start">{icon ?? <ToastIcon />}</Box>
417
417
  ) : null}
418
- <Box flex={1} gap="1">
418
+ <Box flex={1} gap="0">
419
419
  {label ? <ToastTitle>{label}</ToastTitle> : null}
420
420
  {description ? (
421
421
  <ToastDescription>{description}</ToastDescription>
@@ -310,6 +310,7 @@ const styles = StyleSheet.create((theme) => ({
310
310
  backgroundColor: resolveThemeColor(background, theme),
311
311
  borderWidth: StyleSheet.hairlineWidth,
312
312
  borderColor: theme.color['border.subtle'],
313
+ ...theme.elevation.xs,
313
314
  }),
314
315
  // Geometry is two finite axes, so it belongs in `variants` rather than in
315
316
  // conditionals: an icon-only cell is an exact square, a labelled one keeps the
@@ -333,6 +334,7 @@ const styles = StyleSheet.create((theme) => ({
333
334
  paddingHorizontal: 10,
334
335
  borderWidth: StyleSheet.hairlineWidth,
335
336
  borderColor: theme.color['border.subtle'],
337
+ ...theme.elevation.xs,
336
338
  },
337
339
  },
338
340
  },
@@ -326,20 +326,26 @@ export const primitives = {
326
326
  'elevation.none.shadowOffset.height': 0,
327
327
  'elevation.none.elevation': 0,
328
328
 
329
+ 'elevation.xs.shadowOpacity': 0.03,
330
+ 'elevation.xs.shadowRadius': 2,
331
+ 'elevation.xs.shadowOffset.width': 0,
332
+ 'elevation.xs.shadowOffset.height': 0.5,
333
+ 'elevation.xs.elevation': 1,
334
+
329
335
  'elevation.sm.shadowOpacity': 0.1,
330
- 'elevation.sm.shadowRadius': 2,
336
+ 'elevation.sm.shadowRadius': 4,
331
337
  'elevation.sm.shadowOffset.width': 0,
332
338
  'elevation.sm.shadowOffset.height': 1,
333
339
  'elevation.sm.elevation': 1,
334
340
 
335
341
  'elevation.md.shadowOpacity': 0.14,
336
- 'elevation.md.shadowRadius': 4,
342
+ 'elevation.md.shadowRadius': 6,
337
343
  'elevation.md.shadowOffset.width': 0,
338
344
  'elevation.md.shadowOffset.height': 2,
339
345
  'elevation.md.elevation': 3,
340
346
 
341
347
  'elevation.lg.shadowOpacity': 0.16,
342
- 'elevation.lg.shadowRadius': 8,
348
+ 'elevation.lg.shadowRadius': 12,
343
349
  'elevation.lg.shadowOffset.width': 0,
344
350
  'elevation.lg.shadowOffset.height': 4,
345
351
  'elevation.lg.elevation': 6,
@@ -66,7 +66,7 @@ export interface ElevationStyle {
66
66
  elevation: number;
67
67
  }
68
68
 
69
- export type ElevationKey = 'none' | 'sm' | 'md' | 'lg' | 'xl';
69
+ export type ElevationKey = 'none' | 'xs' | 'sm' | 'md' | 'lg' | 'xl';
70
70
 
71
71
  export type ElevationScale = Record<ElevationKey, ElevationStyle>;
72
72
 
@@ -1,166 +0,0 @@
1
- "use strict";
2
-
3
- import { View } from "react-native-unistyles/components/native/View";
4
- import { FlashList } from '@shopify/flash-list';
5
- import Animated, { useAnimatedScrollHandler, useComposedEventHandler } from 'react-native-reanimated';
6
- import { StyleSheet } from 'react-native-unistyles';
7
- import { resolveScreenMargin } from "../../theme/screen-margin.js";
8
- import { PortalHost } from "../portal/index.js";
9
- import { BottomSafeArea } from "./parts/BottomSafeArea.js";
10
- import { renderScreenPlaceholder } from "./parts/ScreenPlaceholder.js";
11
- import { SCREEN_HEADER_PORTAL_HOST, useScreen } from "./ScreenContext.js";
12
- import { hasXMargin, hasYMargin, renderListHeader } from "./utils.js";
13
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
14
- const AnimatedFlashList = Animated.createAnimatedComponent(FlashList);
15
- /**
16
- * `FlashList` variant of `Screen.ScrollView`: mirrors scroll offset into the
17
- * screen's shared `scrollY`, hosts the portal target above the list, and
18
- * applies token-driven content padding.
19
- *
20
- * Requires `@shopify/flash-list` — it is a peer dependency of
21
- * `react-native-terra-ui` and must be installed in the consuming app.
22
- *
23
- * Note: unlike `Screen.FlatList`, this does not bind the screen's shared
24
- * imperative `scrollRef` — `FlashList`'s ref exposes a different (non
25
- * Reanimated-compatible) imperative API.
26
- *
27
- * Shares `loading` / `LoadingComponent` / `EmptyComponent` / `margins` /
28
- * `horizontal` with `Screen.ScrollView`, so a screen can swap one container for
29
- * another without relearning its API.
30
- *
31
- * @example
32
- * ```tsx
33
- * <Screen.FlashList data={items} renderItem={({ item }) => <Row item={item} />} />
34
- * ```
35
- *
36
- * @example Loading and empty placeholders
37
- * ```tsx
38
- * <Screen.FlashList
39
- * data={items}
40
- * loading={isLoading}
41
- * EmptyComponent={<EmptyState icon="status.info" title="Nothing yet" fill />}
42
- * renderItem={({ item }) => <Row item={item} />}
43
- * />
44
- * ```
45
- */
46
- export function ScreenFlashList({
47
- data,
48
- style,
49
- contentContainerStyle,
50
- ListHeaderComponent,
51
- ListFooterComponent,
52
- ListEmptyComponent,
53
- horizontal = false,
54
- loading = false,
55
- LoadingComponent,
56
- EmptyComponent,
57
- margins,
58
- bottomInset,
59
- onScroll,
60
- ...rest
61
- }) {
62
- if (FlashList == null) {
63
- throw new Error('[react-native-terra-ui] Screen.FlashList requires "@shopify/flash-list" to be installed in your app. Run `yarn add @shopify/flash-list` (or the npm/pnpm equivalent) and rebuild.');
64
- }
65
- const {
66
- background,
67
- scrollHandler,
68
- headerSnapOffsets,
69
- margins: screenMargins,
70
- hasHeader
71
- } = useScreen();
72
- const resolvedMargins = margins ?? screenMargins;
73
- // The placeholder rides in on `ListEmptyComponent` rather than replacing the
74
- // list, so the header portal and snap offsets stay put. While loading the
75
- // list is fed an empty `data` so that slot is the one that renders.
76
- const placeholder = renderScreenPlaceholder({
77
- loading,
78
- LoadingComponent,
79
- EmptyComponent,
80
- isEmpty: !data || data.length === 0
81
- });
82
- const jsScrollHandler = useAnimatedScrollHandler(event => {
83
- if (onScroll) onScroll(event);
84
- }, [onScroll]);
85
- const composedHandler = useComposedEventHandler([scrollHandler, jsScrollHandler]);
86
-
87
- // `AnimatedFlashList` is typed for `unknown` items, so the remaining props
88
- // are cast back to its prop type — minus the ones set explicitly below,
89
- // which the spread would otherwise re-supply.
90
- const listProps = rest;
91
-
92
- // A caller naming its own `bottomInset` has taken the bottom over entirely,
93
- // and a horizontal list has no bottom edge to clear.
94
- const needsBottomSafeArea = bottomInset === undefined && !horizontal;
95
- const footerComponent = /*#__PURE__*/_jsxs(_Fragment, {
96
- children: [renderListHeader(ListFooterComponent), needsBottomSafeArea ? /*#__PURE__*/_jsx(BottomSafeArea, {}) : null]
97
- });
98
- const headerComponent = /*#__PURE__*/_jsxs(_Fragment, {
99
- children: [/*#__PURE__*/_jsx(View, {
100
- style: styles.headerWrapper(resolvedMargins),
101
- children: /*#__PURE__*/_jsx(PortalHost, {
102
- name: SCREEN_HEADER_PORTAL_HOST
103
- })
104
- }), renderListHeader(ListHeaderComponent)]
105
- });
106
- return /*#__PURE__*/_jsx(AnimatedFlashList, {
107
- data: loading ? [] : data,
108
- style: [{
109
- backgroundColor: background
110
- }, style],
111
- horizontal: horizontal,
112
- contentInsetAdjustmentBehavior: hasHeader ? 'never' : undefined,
113
- contentContainerStyle: [styles.content(resolvedMargins, hasHeader, bottomInset), contentContainerStyle],
114
- ListHeaderComponent: headerComponent,
115
- ListFooterComponent: footerComponent,
116
- ListEmptyComponent: placeholder ?? ListEmptyComponent,
117
- showsVerticalScrollIndicator: false,
118
- scrollEventThrottle: 16,
119
- snapToOffsets: headerSnapOffsets,
120
- ...listProps,
121
- onScroll: composedHandler
122
- });
123
- }
124
-
125
- // `resolveScreenMargin` is called *inside* each dynamic function below, not
126
- // hoisted to the factory's top level — the Babel plugin only attributes a
127
- // runtime dependency (here, breakpoint) to a style key when the `rt`/
128
- // `runtime` read it derives from sits inside that key's own value. Hoisting
129
- // it would silently drop the dependency, so the margin would freeze at
130
- // whatever breakpoint was active on mount and never update on rotation.
131
- const styles = StyleSheet.create((theme, runtime) => ({
132
- content: (margins, hasHeader, bottomInset) => {
133
- const {
134
- x: marginX,
135
- y: marginY
136
- } = resolveScreenMargin(theme, runtime.breakpoint);
137
- return {
138
- flexGrow: 1,
139
- // The header is absolutely positioned, so the list reserves its full
140
- // height — bar plus top safe area. This assumes the scroll view does not
141
- // also get UIKit's automatic inset adjustment: on a native tab screen
142
- // that means `disableAutomaticContentInsets` on the tab, or the two
143
- // insets are counted twice.
144
- paddingTop: (hasHeader ? theme.layout.header.height + runtime.insets.top : 0) + (hasYMargin(margins) ? marginY : 0),
145
- paddingHorizontal: hasXMargin(margins) ? marginX : 0,
146
- // The safe area is `BottomSafeArea`'s job; counting it here as well
147
- // would leave a gap the height of the gesture bar.
148
- paddingBottom: bottomInset ?? (hasYMargin(margins) ? marginY : 0),
149
- uni__dependencies: [0, 3, 9]
150
- };
151
- },
152
- safeArea: {
153
- height: runtime.insets.top,
154
- uni__dependencies: [9]
155
- },
156
- headerWrapper: margins => {
157
- const {
158
- x: marginX
159
- } = resolveScreenMargin(theme, runtime.breakpoint);
160
- return {
161
- marginHorizontal: hasXMargin(margins) ? -marginX : 0,
162
- uni__dependencies: [0, 3]
163
- };
164
- }
165
- }));
166
- //# sourceMappingURL=ScreenFlashList.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["FlashList","Animated","useAnimatedScrollHandler","useComposedEventHandler","StyleSheet","resolveScreenMargin","PortalHost","BottomSafeArea","renderScreenPlaceholder","SCREEN_HEADER_PORTAL_HOST","useScreen","hasXMargin","hasYMargin","renderListHeader","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","AnimatedFlashList","createAnimatedComponent","ScreenFlashList","data","style","contentContainerStyle","ListHeaderComponent","ListFooterComponent","ListEmptyComponent","horizontal","loading","LoadingComponent","EmptyComponent","margins","bottomInset","onScroll","rest","Error","background","scrollHandler","headerSnapOffsets","screenMargins","hasHeader","resolvedMargins","placeholder","isEmpty","length","jsScrollHandler","event","composedHandler","listProps","needsBottomSafeArea","undefined","footerComponent","children","headerComponent","View","styles","headerWrapper","name","backgroundColor","contentInsetAdjustmentBehavior","content","showsVerticalScrollIndicator","scrollEventThrottle","snapToOffsets","create","theme","runtime","x","marginX","y","marginY","breakpoint","flexGrow","paddingTop","layout","header","height","insets","top","paddingHorizontal","paddingBottom","uni__dependencies","safeArea","marginHorizontal"],"sourceRoot":"../../../../src","sources":["components/screen/ScreenFlashList.tsx"],"mappings":";;;AAAA,SAASA,SAAS,QAA6B,qBAAqB;AAOpE,OAAOC,QAAQ,IACbC,wBAAwB,EACxBC,uBAAuB,QAClB,yBAAyB;AAEhC,SAASC,UAAU,QAAQ,wBAAwB;AAEnD,SAASC,mBAAmB;AAC5B,SAASC,UAAU;AACnB,SAASC,cAAc;AACvB,SAASC,uBAAuB;AAChC,SAASC,yBAAyB,EAAEC,SAAS;AAE7C,SAASC,UAAU,EAAEC,UAAU,EAAEC,gBAAgB;AAAkB,SAAAC,GAAA,IAAAC,IAAA,EA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AACA;AACA;AACA;AACA,MAAMQ,MAAM,GAAGrD,UAAU,CAAC8D,MAAM,CAAC,CAACC,KAAK,EAAEC,OAAO,MAAM;EACpDN,OAAO,EAAEA,CACP7B,OAAsB,EACtBS,SAAkB,EAClBR,WAA+B,KAC5B;IACH,MAAM;MAAEmC,CAAC,EAAEC,OAAO;MAAEC,CAAC,EAAEC;IAAQ,CAAC,GAAGnE,mBAAmB,CACpD8D,KAAK,EACLC,OAAO,CAACK,UACV,CAAC;IACD,OAAO;MACLC,QAAQ,EAAE,CAAC;MACX;MACA;MACA;MACA;MACA;MACAC,UAAU,EACR,CAACjC,SAAS,GAAGyB,KAAK,CAACS,MAAM,CAACC,MAAM,CAACC,MAAM,GAAGV,OAAO,CAACW,MAAM,CAACC,GAAG,GAAG,CAAC,KAC/DpE,UAAU,CAACqB,OAAO,CAAC,GAAGuC,OAAO,GAAG,CAAC,CAAC;MACrCS,iBAAiB,EAAEtE,UAAU,CAACsB,OAAO,CAAC,GAAGqC,OAAO,GAAG,CAAC;MACpD;MACA;MACAY,aAAa,EAAEhD,WAAW,KAAKtB,UAAU,CAACqB,OAAO,CAAC,GAAGuC,OAAO,GAAG,CAAC,CAAC;MAAAW,iBAAA;IACnE,CAAC;EACH,CAAC;EACDC,QAAQ,EAAE;IACRN,MAAM,EAAEV,OAAO,CAACW,MAAM,CAACC,GAAG;IAAAG,iBAAA;EAC5B,CAAC;EACDzB,aAAa,EAAGzB,OAAsB,IAAK;IACzC,MAAM;MAAEoC,CAAC,EAAEC;IAAQ,CAAC,GAAGjE,mBAAmB,CAAC8D,KAAK,EAAEC,OAAO,CAACK,UAAU,CAAC;IACrE,OAAO;MACLY,gBAAgB,EAAE1E,UAAU,CAACsB,OAAO,CAAC,GAAG,CAACqC,OAAO,GAAG,CAAC;MAAAa,iBAAA;IACtD,CAAC;EACH;AACF,CAAC,CAAC,CAAC","ignoreList":[]}
@@ -1,43 +0,0 @@
1
- import { type FlashListProps } from '@shopify/flash-list';
2
- import type { ScreenScrollableProps } from './types.js';
3
- export interface ScreenFlashListProps<T> extends Omit<FlashListProps<T>, 'horizontal'>, ScreenScrollableProps {
4
- /**
5
- * Extra bottom padding on the list content — clearance for a tab bar or home
6
- * indicator. Defaults to the `layout.screen.margin.y` token when margins are
7
- * enabled, otherwise `0`.
8
- */
9
- bottomInset?: number;
10
- }
11
- /**
12
- * `FlashList` variant of `Screen.ScrollView`: mirrors scroll offset into the
13
- * screen's shared `scrollY`, hosts the portal target above the list, and
14
- * applies token-driven content padding.
15
- *
16
- * Requires `@shopify/flash-list` — it is a peer dependency of
17
- * `react-native-terra-ui` and must be installed in the consuming app.
18
- *
19
- * Note: unlike `Screen.FlatList`, this does not bind the screen's shared
20
- * imperative `scrollRef` — `FlashList`'s ref exposes a different (non
21
- * Reanimated-compatible) imperative API.
22
- *
23
- * Shares `loading` / `LoadingComponent` / `EmptyComponent` / `margins` /
24
- * `horizontal` with `Screen.ScrollView`, so a screen can swap one container for
25
- * another without relearning its API.
26
- *
27
- * @example
28
- * ```tsx
29
- * <Screen.FlashList data={items} renderItem={({ item }) => <Row item={item} />} />
30
- * ```
31
- *
32
- * @example Loading and empty placeholders
33
- * ```tsx
34
- * <Screen.FlashList
35
- * data={items}
36
- * loading={isLoading}
37
- * EmptyComponent={<EmptyState icon="status.info" title="Nothing yet" fill />}
38
- * renderItem={({ item }) => <Row item={item} />}
39
- * />
40
- * ```
41
- */
42
- export declare function ScreenFlashList<T>({ data, style, contentContainerStyle, ListHeaderComponent, ListFooterComponent, ListEmptyComponent, horizontal, loading, LoadingComponent, EmptyComponent, margins, bottomInset, onScroll, ...rest }: ScreenFlashListProps<T>): import("react").JSX.Element;
43
- //# sourceMappingURL=ScreenFlashList.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ScreenFlashList.d.ts","sourceRoot":"","sources":["../../../../../src/components/screen/ScreenFlashList.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAmBrE,OAAO,KAAK,EAAiB,qBAAqB,EAAE,MAAM,YAAS,CAAC;AAOpE,MAAM,WAAW,oBAAoB,CAAC,CAAC,CACrC,SAAQ,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,YAAY,CAAC,EAC3C,qBAAqB;IACvB;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,EACjC,IAAI,EACJ,KAAK,EACL,qBAAqB,EACrB,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,EAClB,UAAkB,EAClB,OAAe,EACf,gBAAgB,EAChB,cAAc,EACd,OAAO,EACP,WAAW,EACX,QAAQ,EACR,GAAG,IAAI,EACR,EAAE,oBAAoB,CAAC,CAAC,CAAC,+BAyFzB"}
@@ -1,216 +0,0 @@
1
- import { FlashList, type FlashListProps } from '@shopify/flash-list';
2
- import type { ComponentType } from 'react';
3
- import {
4
- type NativeScrollEvent,
5
- type NativeSyntheticEvent,
6
- View,
7
- } from 'react-native';
8
- import Animated, {
9
- useAnimatedScrollHandler,
10
- useComposedEventHandler,
11
- } from 'react-native-reanimated';
12
-
13
- import { StyleSheet } from 'react-native-unistyles';
14
-
15
- import { resolveScreenMargin } from '#theme/screen-margin';
16
- import { PortalHost } from '../portal';
17
- import { BottomSafeArea } from './parts/BottomSafeArea';
18
- import { renderScreenPlaceholder } from './parts/ScreenPlaceholder';
19
- import { SCREEN_HEADER_PORTAL_HOST, useScreen } from './ScreenContext';
20
- import type { ScreenMargins, ScreenScrollableProps } from './types';
21
- import { hasXMargin, hasYMargin, renderListHeader } from './utils';
22
-
23
- const AnimatedFlashList = Animated.createAnimatedComponent(
24
- FlashList as unknown as ComponentType<FlashListProps<unknown>>
25
- );
26
-
27
- export interface ScreenFlashListProps<T>
28
- extends Omit<FlashListProps<T>, 'horizontal'>,
29
- ScreenScrollableProps {
30
- /**
31
- * Extra bottom padding on the list content — clearance for a tab bar or home
32
- * indicator. Defaults to the `layout.screen.margin.y` token when margins are
33
- * enabled, otherwise `0`.
34
- */
35
- bottomInset?: number;
36
- }
37
-
38
- /**
39
- * `FlashList` variant of `Screen.ScrollView`: mirrors scroll offset into the
40
- * screen's shared `scrollY`, hosts the portal target above the list, and
41
- * applies token-driven content padding.
42
- *
43
- * Requires `@shopify/flash-list` — it is a peer dependency of
44
- * `react-native-terra-ui` and must be installed in the consuming app.
45
- *
46
- * Note: unlike `Screen.FlatList`, this does not bind the screen's shared
47
- * imperative `scrollRef` — `FlashList`'s ref exposes a different (non
48
- * Reanimated-compatible) imperative API.
49
- *
50
- * Shares `loading` / `LoadingComponent` / `EmptyComponent` / `margins` /
51
- * `horizontal` with `Screen.ScrollView`, so a screen can swap one container for
52
- * another without relearning its API.
53
- *
54
- * @example
55
- * ```tsx
56
- * <Screen.FlashList data={items} renderItem={({ item }) => <Row item={item} />} />
57
- * ```
58
- *
59
- * @example Loading and empty placeholders
60
- * ```tsx
61
- * <Screen.FlashList
62
- * data={items}
63
- * loading={isLoading}
64
- * EmptyComponent={<EmptyState icon="status.info" title="Nothing yet" fill />}
65
- * renderItem={({ item }) => <Row item={item} />}
66
- * />
67
- * ```
68
- */
69
- export function ScreenFlashList<T>({
70
- data,
71
- style,
72
- contentContainerStyle,
73
- ListHeaderComponent,
74
- ListFooterComponent,
75
- ListEmptyComponent,
76
- horizontal = false,
77
- loading = false,
78
- LoadingComponent,
79
- EmptyComponent,
80
- margins,
81
- bottomInset,
82
- onScroll,
83
- ...rest
84
- }: ScreenFlashListProps<T>) {
85
- if (FlashList == null) {
86
- throw new Error(
87
- '[react-native-terra-ui] Screen.FlashList requires "@shopify/flash-list" to be installed in your app. Run `yarn add @shopify/flash-list` (or the npm/pnpm equivalent) and rebuild.'
88
- );
89
- }
90
-
91
- const {
92
- background,
93
- scrollHandler,
94
- headerSnapOffsets,
95
- margins: screenMargins,
96
- hasHeader,
97
- } = useScreen();
98
-
99
- const resolvedMargins = margins ?? screenMargins;
100
- // The placeholder rides in on `ListEmptyComponent` rather than replacing the
101
- // list, so the header portal and snap offsets stay put. While loading the
102
- // list is fed an empty `data` so that slot is the one that renders.
103
- const placeholder = renderScreenPlaceholder({
104
- loading,
105
- LoadingComponent,
106
- EmptyComponent,
107
- isEmpty: !data || data.length === 0,
108
- });
109
-
110
- const jsScrollHandler = useAnimatedScrollHandler(
111
- (event) => {
112
- if (onScroll)
113
- onScroll(event as unknown as NativeSyntheticEvent<NativeScrollEvent>);
114
- },
115
- [onScroll]
116
- );
117
-
118
- const composedHandler = useComposedEventHandler([
119
- scrollHandler,
120
- jsScrollHandler,
121
- ]);
122
-
123
- // `AnimatedFlashList` is typed for `unknown` items, so the remaining props
124
- // are cast back to its prop type — minus the ones set explicitly below,
125
- // which the spread would otherwise re-supply.
126
- const listProps = rest as Omit<FlashListProps<unknown>, 'data' | 'onScroll'>;
127
-
128
- // A caller naming its own `bottomInset` has taken the bottom over entirely,
129
- // and a horizontal list has no bottom edge to clear.
130
- const needsBottomSafeArea = bottomInset === undefined && !horizontal;
131
-
132
- const footerComponent = (
133
- <>
134
- {renderListHeader(ListFooterComponent)}
135
- {needsBottomSafeArea ? <BottomSafeArea /> : null}
136
- </>
137
- );
138
-
139
- const headerComponent = (
140
- <>
141
- {/* `headerWrapper`'s negative margin cancels the list's inherited
142
- content padding for the portaled header (`LargeTitlePortalContent`
143
- etc. manage their own horizontal padding) — a caller's own
144
- `ListHeaderComponent` has no such self-padding, so it stays outside
145
- this wrapper and gets the list's normal item padding instead. */}
146
- <View style={styles.headerWrapper(resolvedMargins)}>
147
- <PortalHost name={SCREEN_HEADER_PORTAL_HOST} />
148
- </View>
149
- {renderListHeader(ListHeaderComponent)}
150
- </>
151
- );
152
-
153
- return (
154
- <AnimatedFlashList
155
- data={loading ? [] : (data as readonly unknown[] | null | undefined)}
156
- style={[{ backgroundColor: background }, style]}
157
- horizontal={horizontal}
158
- contentInsetAdjustmentBehavior={hasHeader ? 'never' : undefined}
159
- contentContainerStyle={[
160
- styles.content(resolvedMargins, hasHeader, bottomInset),
161
- contentContainerStyle,
162
- ]}
163
- ListHeaderComponent={headerComponent}
164
- ListFooterComponent={footerComponent}
165
- ListEmptyComponent={placeholder ?? ListEmptyComponent}
166
- showsVerticalScrollIndicator={false}
167
- scrollEventThrottle={16}
168
- snapToOffsets={headerSnapOffsets}
169
- {...listProps}
170
- onScroll={composedHandler}
171
- />
172
- );
173
- }
174
-
175
- // `resolveScreenMargin` is called *inside* each dynamic function below, not
176
- // hoisted to the factory's top level — the Babel plugin only attributes a
177
- // runtime dependency (here, breakpoint) to a style key when the `rt`/
178
- // `runtime` read it derives from sits inside that key's own value. Hoisting
179
- // it would silently drop the dependency, so the margin would freeze at
180
- // whatever breakpoint was active on mount and never update on rotation.
181
- const styles = StyleSheet.create((theme, runtime) => ({
182
- content: (
183
- margins: ScreenMargins,
184
- hasHeader: boolean,
185
- bottomInset: number | undefined
186
- ) => {
187
- const { x: marginX, y: marginY } = resolveScreenMargin(
188
- theme,
189
- runtime.breakpoint
190
- );
191
- return {
192
- flexGrow: 1,
193
- // The header is absolutely positioned, so the list reserves its full
194
- // height — bar plus top safe area. This assumes the scroll view does not
195
- // also get UIKit's automatic inset adjustment: on a native tab screen
196
- // that means `disableAutomaticContentInsets` on the tab, or the two
197
- // insets are counted twice.
198
- paddingTop:
199
- (hasHeader ? theme.layout.header.height + runtime.insets.top : 0) +
200
- (hasYMargin(margins) ? marginY : 0),
201
- paddingHorizontal: hasXMargin(margins) ? marginX : 0,
202
- // The safe area is `BottomSafeArea`'s job; counting it here as well
203
- // would leave a gap the height of the gesture bar.
204
- paddingBottom: bottomInset ?? (hasYMargin(margins) ? marginY : 0),
205
- };
206
- },
207
- safeArea: {
208
- height: runtime.insets.top,
209
- },
210
- headerWrapper: (margins: ScreenMargins) => {
211
- const { x: marginX } = resolveScreenMargin(theme, runtime.breakpoint);
212
- return {
213
- marginHorizontal: hasXMargin(margins) ? -marginX : 0,
214
- };
215
- },
216
- }));