@openpeepshq/rn-components 0.8.0 → 0.8.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openpeepshq/rn-components",
3
- "version": "0.8.0",
3
+ "version": "0.8.1",
4
4
  "description": "React Native community screens and shared UI (extracted from the Black Ambition app) for the OpenPeeps stack.",
5
5
  "source": "./src/index.ts",
6
6
  "main": "./src/index.ts",
@@ -142,8 +142,8 @@
142
142
  "timezones-list": "^3.1.0",
143
143
  "validator": "^13.15.23",
144
144
  "zustand": "^5.0.3",
145
- "@openpeepshq/react": "^0.8.0",
146
- "@openpeepshq/common": "^0.4.0"
145
+ "@openpeepshq/common": "^0.4.0",
146
+ "@openpeepshq/react": "^0.8.1"
147
147
  },
148
148
  "devDependencies": {
149
149
  "@babel/core": "^7.26.7",
@@ -23,12 +23,14 @@ const { width: SCREEN_WIDTH } = Dimensions.get('window');
23
23
 
24
24
  interface AudioPickerSheetProps {
25
25
  onSelect: (audioAttachments: MediaAttachment[]) => void | Promise<void>;
26
+ /** When false, the sheet selects a single file (no multiple toggle). */
27
+ multiple?: boolean;
26
28
  }
27
29
 
28
30
  export const AudioPickerSheet = forwardRef<
29
31
  BottomSheetModal,
30
32
  AudioPickerSheetProps
31
- >(({ onSelect }, ref) => {
33
+ >(({ onSelect, multiple = true }, ref) => {
32
34
  const [selectedAudios, setSelectedAudios] = useState<string[]>([]);
33
35
  const [isMultipleSelect, setIsMultipleSelect] = useState(false);
34
36
  const [currentAudioIndex, setCurrentAudioIndex] = useState(0);
@@ -122,39 +124,33 @@ export const AudioPickerSheet = forwardRef<
122
124
  <View className="flex-1">
123
125
  {renderSelectedAudiosPreview()}
124
126
 
125
- <View className="flex-row justify-between items-center px-4 py-3">
126
- <View className="flex-row items-center gap-4">
127
- <Button
128
- variant={isMultipleSelect ? 'secondary' : 'ghost'}
129
- size={'sm'}
130
- onPress={() => setIsMultipleSelect(!isMultipleSelect)}
131
- >
132
- <Text className="text-foreground text-base font-medium">
133
- {t('common.form.selectMultiple')}
134
- </Text>
135
- </Button>
136
- {/* <Button
137
- variant={'outline'}
138
- size={'icon'}
139
- className="rounded-full"
140
- onPress={handleMicrophonePress}>
141
- <MicIcon size={16} className="text-foreground" />
142
- </Button> */}
127
+ {multiple ? (
128
+ <View className="flex-row justify-between items-center px-4 py-3">
129
+ <View className="flex-row items-center gap-4">
130
+ <Button
131
+ variant={isMultipleSelect ? 'secondary' : 'ghost'}
132
+ size={'sm'}
133
+ onPress={() => setIsMultipleSelect(!isMultipleSelect)}
134
+ >
135
+ <Text className="text-foreground text-base font-medium">
136
+ {t('common.form.selectMultiple')}
137
+ </Text>
138
+ </Button>
139
+ </View>
143
140
  </View>
144
- </View>
141
+ ) : null}
145
142
 
146
143
  <Button
147
144
  variant={'ghost'}
148
145
  onPress={async () => {
149
146
  const result = await pick({
150
147
  type: 'audio',
151
- multiple: isMultipleSelect,
148
+ multiple: multiple && isMultipleSelect,
152
149
  });
153
150
  if (result) {
154
- setSelectedAudios([
155
- ...selectedAudios,
156
- ...result.map((r) => r.uri),
157
- ]);
151
+ const uris = result.map((r) => r.uri);
152
+ // Single mode replaces the pick; multiple mode appends.
153
+ setSelectedAudios(multiple ? [...selectedAudios, ...uris] : uris);
158
154
  }
159
155
  }}
160
156
  >
@@ -39,6 +39,8 @@ import {
39
39
 
40
40
  interface DocumentPickerSheetProps {
41
41
  onSelect: (documentAttachments: MediaAttachment[]) => void | Promise<void>;
42
+ /** When false, the picker is limited to a single file. */
43
+ multiple?: boolean;
42
44
  }
43
45
 
44
46
  export type DocumentPickerSheetHandle = {
@@ -89,7 +91,7 @@ const mergePickedDocs = (
89
91
  export const DocumentPickerSheet = forwardRef<
90
92
  DocumentPickerSheetHandle,
91
93
  DocumentPickerSheetProps
92
- >(({ onSelect }, ref) => {
94
+ >(({ onSelect, multiple = true }, ref) => {
93
95
  const sheetRef = useRef<BottomSheetModal>(null);
94
96
  const descriptionSheetRef = useRef<BottomSheetModal>(null);
95
97
 
@@ -111,14 +113,16 @@ export const DocumentPickerSheet = forwardRef<
111
113
 
112
114
  const results = await pick({
113
115
  type: [...ATTACHMENT_DOCUMENT_TYPES],
114
- allowMultiSelection: true,
116
+ allowMultiSelection: multiple,
115
117
  mode: 'import',
116
118
  });
117
119
 
118
- setSelectedDocs((prev) => mergePickedDocs(prev, results));
120
+ setSelectedDocs((prev) =>
121
+ multiple ? mergePickedDocs(prev, results) : results
122
+ );
119
123
  return results;
120
124
  },
121
- []
125
+ [multiple]
122
126
  );
123
127
 
124
128
  const open = useCallback(async () => {
@@ -317,18 +321,20 @@ export const DocumentPickerSheet = forwardRef<
317
321
  </View>
318
322
  ))}
319
323
 
320
- <Button
321
- variant="ghost"
322
- className="flex-row items-center justify-center mt-2 border border-dashed border-border"
323
- onPress={handlePickDocument}
324
- >
325
- <PlusIcon size={16} className="text-foreground mr-2" />
326
- <Text className="text-foreground font-medium">
327
- {t('form.documentInput.addMore', {
328
- defaultValue: 'Add more files',
329
- })}
330
- </Text>
331
- </Button>
324
+ {multiple ? (
325
+ <Button
326
+ variant="ghost"
327
+ className="flex-row items-center justify-center mt-2 border border-dashed border-border"
328
+ onPress={handlePickDocument}
329
+ >
330
+ <PlusIcon size={16} className="text-foreground mr-2" />
331
+ <Text className="text-foreground font-medium">
332
+ {t('form.documentInput.addMore', {
333
+ defaultValue: 'Add more files',
334
+ })}
335
+ </Text>
336
+ </Button>
337
+ ) : null}
332
338
  </View>
333
339
  );
334
340
  };
@@ -13,6 +13,8 @@ import { bottomSheetClose } from '../../../../lib/bottom-sheet-ref';
13
13
 
14
14
  interface VideoPickerSheetProps {
15
15
  onSelect: (videoAttachments: MediaAttachment[]) => void | Promise<void>;
16
+ /** When false, the library picker is limited to a single video. */
17
+ multiple?: boolean;
16
18
  }
17
19
 
18
20
  // Videos are selected via the system photo picker (launchImageLibrary), which
@@ -21,7 +23,7 @@ interface VideoPickerSheetProps {
21
23
  export const VideoPickerSheet = forwardRef<
22
24
  BottomSheetModal,
23
25
  VideoPickerSheetProps
24
- >(({ onSelect }, ref) => {
26
+ >(({ onSelect, multiple = true }, ref) => {
25
27
  const [isLoading, setIsLoading] = useState(false);
26
28
  const { t } = useTranslation();
27
29
  const { openpeepsApi } = useOpenpeeps();
@@ -54,7 +56,7 @@ export const VideoPickerSheet = forwardRef<
54
56
  const handleLibrary = async () => {
55
57
  const result = await launchImageLibrary({
56
58
  mediaType: 'video',
57
- selectionLimit: 0,
59
+ selectionLimit: multiple ? 0 : 1,
58
60
  });
59
61
  if (result.didCancel || !result.assets?.length) {
60
62
  return;
@@ -343,9 +343,22 @@ export const ResourceForm = ({
343
343
  ) : null}
344
344
  </View>
345
345
  <ImagePickerSheet ref={imageRef} onSelect={addAttachments} />
346
- <VideoPickerSheet ref={videoRef} onSelect={addAttachments} />
347
- <AudioPickerSheet ref={audioRef} onSelect={addAttachments} />
348
- <DocumentPickerSheet ref={documentRef} onSelect={addAttachments} />
346
+ {/* Only galleries take more than one file; other kinds pick one. */}
347
+ <VideoPickerSheet
348
+ ref={videoRef}
349
+ multiple={false}
350
+ onSelect={addAttachments}
351
+ />
352
+ <AudioPickerSheet
353
+ ref={audioRef}
354
+ multiple={false}
355
+ onSelect={addAttachments}
356
+ />
357
+ <DocumentPickerSheet
358
+ ref={documentRef}
359
+ multiple={false}
360
+ onSelect={addAttachments}
361
+ />
349
362
  </View>
350
363
  );
351
364
  };