@applicaster/zapp-react-native-ui-components 16.0.0-rc.61 → 16.0.0-rc.63

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.
@@ -61,7 +61,6 @@ type ModalComponentProps = {
61
61
  maxHeight?: number;
62
62
  dismiss: () => void;
63
63
  headerComponent?: React.ComponentType<any>;
64
- headerComponentProps?: Record<string, any>;
65
64
  buttonComponent?: React.ComponentType;
66
65
  iconProps?: ItemIconProps | ((theme: PluginConfiguration) => ItemIconProps);
67
66
  itemProps?:
@@ -94,7 +93,6 @@ export function BottomSheetModalContent(props: ModalComponentProps) {
94
93
  summary,
95
94
  title,
96
95
  headerComponent,
97
- headerComponentProps,
98
96
  viewModel = null,
99
97
  buttonComponent: ButtonComponent = Button,
100
98
  getSelectedItemIcon = ({
@@ -463,7 +461,6 @@ export function BottomSheetModalContent(props: ModalComponentProps) {
463
461
  >
464
462
  <BottomSheetDragArea>
465
463
  <Header
466
- {...(headerComponentProps || {})}
467
464
  dismiss={dismiss}
468
465
  configuration={theme}
469
466
  summary={summary}
@@ -0,0 +1,102 @@
1
+ import React from "react";
2
+ import { Text, View, ViewStyle, ScrollView } from "react-native";
3
+
4
+ const DEFAULT_HEADERS: any[] = [];
5
+ const DEFAULT_SORTABLE_DATA: any[] = [];
6
+
7
+ const renderHeaderComponent = (component: any) => {
8
+ if (!component) return null;
9
+ if (React.isValidElement(component)) return component;
10
+
11
+ if (typeof component === "function") {
12
+ const HeaderComponent = component;
13
+
14
+ return <HeaderComponent />;
15
+ }
16
+
17
+ return null;
18
+ };
19
+
20
+ const SortableListHeader = ({
21
+ title,
22
+ style,
23
+ }: {
24
+ title?: string;
25
+ style?: ViewStyle;
26
+ }) => {
27
+ const displayTitle = typeof title === "string" ? title : String(title ?? "");
28
+
29
+ return (
30
+ <View style={style}>
31
+ {displayTitle ? <Text>{displayTitle}</Text> : null}
32
+ </View>
33
+ );
34
+ };
35
+
36
+ export type SortableListProps = {
37
+ scrollViewStyle?: ViewStyle;
38
+ contentContainerStyle?: ViewStyle;
39
+ itemStyle?: ViewStyle;
40
+ headerStyle?: ViewStyle;
41
+ columns?: number;
42
+ rowGap?: number;
43
+ columnGap?: number;
44
+ spacing?: number;
45
+ keyExtractor?: (item: any, index?: number) => string;
46
+ renderItem: ({
47
+ item,
48
+ index,
49
+ renderHandle,
50
+ }: {
51
+ item: any;
52
+ index: number;
53
+ renderHandle: (children: React.ReactElement) => React.ReactElement;
54
+ }) => React.ReactNode;
55
+ sortableData?: any[];
56
+ headers?: { index: number; title?: string; component: any }[];
57
+ onDragEnd?: (params: {
58
+ fromIndex?: number;
59
+ toIndex?: number;
60
+ from?: number;
61
+ to?: number;
62
+ data: any[];
63
+ }) => void;
64
+ };
65
+
66
+ export const SortableList = ({
67
+ scrollViewStyle,
68
+ contentContainerStyle,
69
+ itemStyle,
70
+ headerStyle,
71
+ keyExtractor = (item, index) =>
72
+ `sortable-item-${item?.id ?? item?.title ?? index}`,
73
+ renderItem,
74
+ sortableData = DEFAULT_SORTABLE_DATA,
75
+ headers = DEFAULT_HEADERS,
76
+ }: SortableListProps) => {
77
+ return (
78
+ <ScrollView
79
+ style={scrollViewStyle}
80
+ contentContainerStyle={contentContainerStyle}
81
+ >
82
+ {(headers || []).map((header, idx) => (
83
+ <View key={`static-header-${idx}`} style={headerStyle}>
84
+ {header.title ? (
85
+ <SortableListHeader title={header.title} />
86
+ ) : (
87
+ renderHeaderComponent(header.component)
88
+ )}
89
+ </View>
90
+ ))}
91
+ {(sortableData || []).map((item, index) => (
92
+ <View key={keyExtractor(item, index)} style={itemStyle}>
93
+ {renderItem({
94
+ item,
95
+ index,
96
+ renderHandle: (children) => children,
97
+ })}
98
+ </View>
99
+ ))}
100
+ </ScrollView>
101
+ );
102
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/zapp-react-native-ui-components",
3
- "version": "16.0.0-rc.61",
3
+ "version": "16.0.0-rc.63",
4
4
  "description": "Applicaster Zapp React Native ui components for the Quick Brick App",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -28,10 +28,10 @@
28
28
  },
29
29
  "homepage": "https://github.com/applicaster/quickbrick#readme",
30
30
  "dependencies": {
31
- "@applicaster/applicaster-types": "16.0.0-rc.61",
32
- "@applicaster/zapp-react-native-bridge": "16.0.0-rc.61",
33
- "@applicaster/zapp-react-native-redux": "16.0.0-rc.61",
34
- "@applicaster/zapp-react-native-utils": "16.0.0-rc.61",
31
+ "@applicaster/applicaster-types": "16.0.0-rc.63",
32
+ "@applicaster/zapp-react-native-bridge": "16.0.0-rc.63",
33
+ "@applicaster/zapp-react-native-redux": "16.0.0-rc.63",
34
+ "@applicaster/zapp-react-native-utils": "16.0.0-rc.63",
35
35
  "fast-json-stable-stringify": "^2.1.0",
36
36
  "promise": "^8.3.0",
37
37
  "react-native-sortables": "1.7.1",