@supportworks/multi-imagepicker 8.0.19 → 8.2.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.
package/changes.md CHANGED
@@ -1,4 +1,8 @@
1
1
 
2
+ # v8.2.0 2026-04-09
3
+ * reverted back to v8.0.16
4
+ * then changed UploadWarningModal to just be a regular component instead of a modal, to fix multiple nested modals issue on older iPads
5
+
2
6
  # v8.0.19 2026-03-31
3
7
  * tweak to attaching
4
8
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@supportworks/multi-imagepicker",
3
- "version": "8.0.19",
3
+ "version": "8.2.0",
4
4
  "description": "Android and iOS customized multiple image picker. For react-native >= 0.60.",
5
5
  "main": "index.js",
6
6
  "author": {
@@ -18,72 +18,6 @@ import { Analytics } from '@supportworks/analytics'
18
18
  import AsyncStorage from '@react-native-async-storage/async-storage'
19
19
  import UploadWarningModal from './UploadWarningModal'
20
20
 
21
- const ADD_IMAGES_LOG_PREFIX = '[AddImages]'
22
-
23
- function getFileExtension (value = '') {
24
- const normalizedValue = String(value || '').split('?')[0]
25
- const lastSlash = normalizedValue.lastIndexOf('/')
26
- const lastDot = normalizedValue.lastIndexOf('.')
27
-
28
- if (lastDot === -1 || lastDot < lastSlash) {
29
- return ''
30
- }
31
-
32
- return normalizedValue.substring(lastDot)
33
- }
34
-
35
- function summarizeImageForLog (img = {}, idx = null) {
36
- const path = img?.path || ''
37
- const filename = img?.filename || ''
38
-
39
- return {
40
- idx,
41
- path,
42
- mime: img?.mime || null,
43
- filename: filename || null,
44
- filenameHasExtension: !!getFileExtension(filename),
45
- defaultName: img?.defaultName || null,
46
- pathExtension: getFileExtension(path) || null,
47
- width: img?.width ?? null,
48
- height: img?.height ?? null,
49
- size: img?.size ?? null,
50
- sourceURL: img?.sourceURL || null,
51
- hasDepthMapUri: !!img?.depthMapUri,
52
- saveToDevice: img?.saveToDevice ?? null,
53
- showToCust: img?.showToCust ?? null,
54
- isValid: img?.isValid ?? null
55
- }
56
- }
57
-
58
- function summarizePayloadForLog (payload = {}) {
59
- const imageArray = Array.isArray(payload?.imageArray) ? payload.imageArray : []
60
- const imageDescArray = Array.isArray(payload?.imageDescArray) ? payload.imageDescArray : []
61
- const imageValidArray = Array.isArray(payload?.imageValidArray) ? payload.imageValidArray : []
62
-
63
- return {
64
- imageSource: payload?.imageSource || null,
65
- index: payload?.index ?? null,
66
- cancelIndex: payload?.cancelIndex ?? null,
67
- imageCount: imageArray.length,
68
- descCount: imageDescArray.length,
69
- validCount: imageValidArray.length,
70
- images: imageArray.map((img, idx) => summarizeImageForLog(img, idx))
71
- }
72
- }
73
-
74
- function logAddImages (message, details = null) {
75
- if (details === null || details === undefined) {
76
- console.log(`${ADD_IMAGES_LOG_PREFIX} ${message}`)
77
- return
78
- }
79
-
80
- try {
81
- console.log(`${ADD_IMAGES_LOG_PREFIX} ${message}: ${JSON.stringify(details)}`)
82
- } catch (err) {
83
- console.log(`${ADD_IMAGES_LOG_PREFIX} ${message}`, details)
84
- }
85
- }
86
-
87
21
  const AddImages = forwardRef((
88
22
  {
89
23
  parentStyle = null, // style passed to MultiImagePicker
@@ -99,7 +33,6 @@ const AddImages = forwardRef((
99
33
  }, ref) => {
100
34
  const [showAttaching, setShowAttaching] = useState(false)
101
35
  const [showAdd, setShowAdd] = useState(false)
102
- const [pendingAttach, setPendingAttach] = useState(false)
103
36
  const [showInfoDialog, setShowInfoDialog] = useState(false)
104
37
  const [allImageDataValid, setAllImageDataValid] = useState(true)
105
38
  const [showToCust, setShowToCust] = useState(false)
@@ -127,7 +60,6 @@ const AddImages = forwardRef((
127
60
  }, [])
128
61
 
129
62
  const triggerAction = useCallback(() => {
130
- logAddImages('triggerAction called', { hasPickerRef: !!pickerRef.current })
131
63
  if (pickerRef.current && typeof pickerRef.current.showActionSheet === 'function') {
132
64
  pickerRef.current.showActionSheet()
133
65
  }
@@ -160,14 +92,6 @@ const AddImages = forwardRef((
160
92
  const addPicturesToProject = useCallback(async () => {
161
93
  // go through all images selected and add to project
162
94
  try {
163
- logAddImages('addPicturesToProject start', {
164
- itemCount: itemsRef.current.length,
165
- imageSource: imgSourceRef.current,
166
- allowSaveToDevice,
167
- saveToDevice,
168
- showToCust,
169
- items: (itemsRef.current || []).map((item, idx) => summarizeImageForLog(item, idx))
170
- })
171
95
  loaderHandler.showLoader('Saving Pictures...')
172
96
 
173
97
  // Save selected images to device camera roll (per-item), only for camera-taken images
@@ -181,157 +105,64 @@ const AddImages = forwardRef((
181
105
  {
182
106
  for (const it of toSave) {
183
107
  try {
184
- logAddImages('CameraRoll.save attempt', summarizeImageForLog(it))
185
108
  await CameraRoll.save(it.path)
186
- logAddImages('CameraRoll.save success', { path: it.path })
187
109
  } catch (err) {
188
- logAddImages('CameraRoll.save failed', {
189
- path: it.path,
190
- error: err?.message || err?.toString?.() || String(err),
191
- stack: err?.stack || null
192
- })
110
+ console.log('CameraRoll.save failed for ' + it.path + '; Error: ' + err)
193
111
  }
194
112
  }
195
113
  }
196
114
  }
197
115
  }
198
116
  } catch (e) {
199
- logAddImages('Error during save-to-device batch', {
200
- error: e?.message || e?.toString?.() || String(e),
201
- stack: e?.stack || null
202
- })
117
+ console.log('Error during save-to-device batch: ' + e)
203
118
  }
204
119
 
205
120
  // Upload/add images to project
206
121
  for (let i = 0; i < itemsRef.current.length; i++) {
207
- const currentItem = itemsRef.current[i]
208
- logAddImages('Uploading item', {
209
- idx: i,
210
- imageSource: imgSourceRef.current,
211
- item: summarizeImageForLog(currentItem, i)
212
- })
213
122
  if (addPicture) {
214
- const addPictureResult = await addPicture(currentItem, currentItem?.desc || '', prospectInst)
215
- logAddImages('addPicture result', { idx: i, result: addPictureResult })
123
+ await addPicture(itemsRef.current[i], itemsRef.current[i]?.desc || '', prospectInst)
216
124
  } else {
217
- const apiResult = await Api.getApi().addOnePictureToProject(currentItem, currentItem?.desc || '', prospectInst)
218
- logAddImages('Api.addOnePictureToProject result', { idx: i, result: apiResult })
125
+ await Api.getApi().addOnePictureToProject(itemsRef.current[i], itemsRef.current[i]?.desc || '', prospectInst)
219
126
  }
220
127
  }
221
128
 
222
129
  loaderHandler.hideLoader()
223
- logAddImages('addPicturesToProject complete', { itemCount: itemsRef.current.length })
224
130
  return true
225
131
  } catch (err) {
226
- logAddImages('addPicturesToProject failed', {
227
- error: err?.message || err?.toString?.() || String(err),
228
- stack: err?.stack || null,
229
- imageSource: imgSourceRef.current,
230
- items: (itemsRef.current || []).map((item, idx) => summarizeImageForLog(item, idx))
231
- })
132
+ console.log('----addPicturesToProject: returning false; ERROR: ' + err.toString())
232
133
  loaderHandler.hideLoader()
233
134
  return false
234
135
  }
235
136
  }, [addPicture, prospectInst, hasAndroidWritePermission, showToCust, saveToDevice, allowSaveToDevice])
236
137
 
237
- const performAttach = useCallback(async () => {
138
+ const onAttach = useCallback(async () => {
238
139
  if (!isMountedRef.current) {
239
140
  return
240
141
  }
241
142
 
242
- logAddImages('performAttach start', {
243
- itemCount: itemsRef.current.length,
244
- imageSource: imgSourceRef.current,
245
- allowEdit,
246
- allowSaveToDevice,
247
- showToCustomerAllowed
248
- })
249
- setShowAttaching(true)
143
+ setShowAttaching(false)
144
+ setShowAdd(false)
250
145
 
251
- try {
252
- const addPicturesResult = await addPicturesToProject()
253
- logAddImages('performAttach addPicturesToProject result', { result: addPicturesResult })
254
- if (allowEdit && allowSaveToDevice) {
255
- await Api.getApi().setDefaultSavePhotosToDevice(saveToDevice)
256
- }
257
- if (allowEdit && showToCustomerAllowed) {
258
- await Api.getApi().setDefaultShowToCustomer(showToCust)
259
- }
260
- Analytics.logEvent('mip_addImages_onAttach', { source_page: 'MultiImagePicker' })
261
- if (callback) {
262
- callback()
263
- }
264
- } finally {
265
- if (isMountedRef.current) {
266
- setShowAttaching(false)
267
- setPendingAttach(false)
268
- }
269
- logAddImages('performAttach end', {
270
- itemCount: itemsRef.current.length,
271
- pendingAttach: false
272
- })
146
+ await addPicturesToProject()
147
+ if (allowEdit && allowSaveToDevice) {
148
+ await Api.getApi().setDefaultSavePhotosToDevice(saveToDevice)
273
149
  }
274
- }, [addPicturesToProject, allowEdit, callback, saveToDevice, allowSaveToDevice, showToCust, showToCustomerAllowed])
275
-
276
- const onAttach = useCallback(() => {
277
- if (!isMountedRef.current) {
278
- return
150
+ if (allowEdit && showToCustomerAllowed) {
151
+ await Api.getApi().setDefaultShowToCustomer(showToCust)
279
152
  }
280
-
281
- logAddImages('onAttach pressed', {
282
- platform: Platform.OS,
283
- showAdd,
284
- itemCount: itemsRef.current.length,
285
- allImageDataValid,
286
- imageSource: imgSourceRef.current
287
- })
288
-
289
- if (Platform.OS === 'ios' && showAdd) {
290
- logAddImages('onAttach deferring until modal closes on iOS', {
291
- itemCount: itemsRef.current.length,
292
- imageSource: imgSourceRef.current
293
- })
294
- setPendingAttach(true)
295
- setShowAdd(false)
296
- return
153
+ Analytics.logEvent('mip_addImages_onAttach', { source_page: 'MultiImagePicker' })
154
+ if (callback) {
155
+ callback()
297
156
  }
298
-
299
- void performAttach()
300
- }, [allImageDataValid, performAttach, showAdd])
301
-
302
- const onAddModalDismiss = useCallback(() => {
303
- logAddImages('onAddModalDismiss fired', {
304
- pendingAttach,
305
- itemCount: itemsRef.current.length,
306
- imageSource: imgSourceRef.current
307
- })
308
- }, [pendingAttach])
309
-
310
- useEffect(() => {
311
- if (!pendingAttach || showAdd) {
312
- return
313
- }
314
-
315
- logAddImages('pendingAttach detected with modal closed, starting performAttach', {
316
- itemCount: itemsRef.current.length,
317
- imageSource: imgSourceRef.current
318
- })
319
- void performAttach()
320
- }, [pendingAttach, performAttach, showAdd])
157
+ }, [addPicturesToProject, allowEdit, callback, saveToDevice, allowSaveToDevice, showToCust, showToCustomerAllowed])
321
158
 
322
159
  const onClose = useCallback(() => {
323
160
  if (!isMountedRef.current) {
324
161
  return
325
162
  }
326
- logAddImages('onClose called', {
327
- itemCount: itemsRef.current.length,
328
- imageSource: imgSourceRef.current,
329
- pendingAttach
330
- })
331
- setPendingAttach(false)
332
163
  setShowAttaching(false)
333
164
  setShowAdd(false)
334
- }, [pendingAttach])
165
+ }, [])
335
166
 
336
167
  const onCloseInfoDialog = useCallback(async (storageVal) => {
337
168
  try {
@@ -452,8 +283,6 @@ const AddImages = forwardRef((
452
283
  // Build unified items list from payload
453
284
  // handle return of selected images from MultiImagePicker
454
285
 
455
- logAddImages('onImageSelect raw payload', summarizePayloadForLog(payload))
456
-
457
286
  const { imageArray = [], imageDescArray = [], imageValidArray = [] } = payload || {}
458
287
  const timestampSeed = Date.now()
459
288
  itemsRef.current = imageArray.map((img, i) => ({
@@ -466,31 +295,9 @@ const AddImages = forwardRef((
466
295
  }))
467
296
  imgSourceRef.current = payload.imageSource
468
297
 
469
- logAddImages('onImageSelect normalized items', {
470
- imageSource: payload?.imageSource || null,
471
- itemCount: itemsRef.current.length,
472
- items: itemsRef.current.map((item, idx) => summarizeImageForLog(item, idx))
473
- })
474
-
475
- if (payload?.imageSource === 'taken') {
476
- const suspiciousTakenItems = itemsRef.current
477
- .map((item, idx) => ({ idx, item }))
478
- .filter(({ item }) => !item?.filename || !getFileExtension(item.filename))
479
- .map(({ idx, item }) => summarizeImageForLog(item, idx))
480
-
481
- if (suspiciousTakenItems.length > 0) {
482
- logAddImages('taken image(s) missing filename extension after normalization', suspiciousTakenItems)
483
- }
484
- }
485
-
486
298
  // init for saving selected images to device camera roll, only for camera-taken images
487
299
  const canSaveToDevice = allowSaveToDevicePlatform && (payload.imageSource === 'taken')
488
300
  setAllowSaveToDevice(canSaveToDevice)
489
- logAddImages('onImageSelect save-to-device capability', {
490
- allowSaveToDevicePlatform,
491
- imageSource: payload?.imageSource || null,
492
- canSaveToDevice
493
- })
494
301
 
495
302
  if (allowEdit) {
496
303
  const [defaultSaveToDevice, defaultShowToCustomer] = await Promise.all([
@@ -498,11 +305,6 @@ const AddImages = forwardRef((
498
305
  showToCustomerAllowed ? Api.getApi().getDefaultShowToCustomer() : Promise.resolve(false)
499
306
  ])
500
307
 
501
- logAddImages('onImageSelect default flags loaded', {
502
- defaultSaveToDevice,
503
- defaultShowToCustomer
504
- })
505
-
506
308
  // initialize per-image flags
507
309
  const initialSaveFlag = canSaveToDevice ? defaultSaveToDevice : false
508
310
  const initialShowFlag = showToCustomerAllowed ? !!defaultShowToCustomer : false
@@ -525,17 +327,8 @@ const AddImages = forwardRef((
525
327
  if (skipped !== 'true') {
526
328
  setShowInfoDialog(true)
527
329
  }
528
- logAddImages('onImageSelect modal shown', {
529
- itemCount: itemsRef.current.length,
530
- skippedUploadWarningDialog: skipped === 'true',
531
- initialSaveFlag,
532
- initialShowFlag
533
- })
534
330
  } catch (e) {
535
- logAddImages('error reading skip dialog pref', {
536
- error: e?.message || e?.toString?.() || String(e),
537
- stack: e?.stack || null
538
- })
331
+ console.log('AddImages: error reading skip dialog pref: ' + e)
539
332
  setShowInfoDialog(true)
540
333
  }
541
334
  }
@@ -544,10 +337,6 @@ const AddImages = forwardRef((
544
337
  if (isMountedRef.current) {
545
338
  setItems([...itemsRef.current])
546
339
  }
547
- logAddImages('allowEdit disabled, attaching immediately', {
548
- itemCount: itemsRef.current.length,
549
- imageSource: payload?.imageSource || null
550
- })
551
340
  await onAttach()
552
341
  }
553
342
  }, [allowEdit, buildDefaultFilename, onAttach, showToCustomerAllowed])
@@ -624,15 +413,9 @@ const AddImages = forwardRef((
624
413
  )
625
414
  }
626
415
 
627
- return (
628
- <>
629
- {!showAdd && (
630
- <MultiImagePicker ref={setPickerRef} hitSlop={hitSlop} maxCount={maxCount} parentStyle={parentStyle} callback={onImageSelect}>
631
- {children}
632
- </MultiImagePicker>
633
- )}
634
-
635
- <Modal visible={showAdd} presentationStyle='fullScreen' animationType='slide' onDismiss={onAddModalDismiss}>
416
+ if (showAdd) {
417
+ return (
418
+ <Modal presentationStyle='fullScreen' animationType='slide'>
636
419
  <ScreenSafeAreaView style={styles.Page} edges={['top','bottom']} includeProvider>
637
420
  <AppBarH8
638
421
  variant='regular'
@@ -668,16 +451,22 @@ const AddImages = forwardRef((
668
451
  disabled={!allImageDataValid}
669
452
  />
670
453
  </View>
671
- </ScreenSafeAreaView>
672
454
 
673
- {Api.getApi().sendPhotosToCRM() && false && (
674
- <UploadWarningModal
675
- visible={showInfoDialog}
676
- onClose={onCloseInfoDialog}
677
- />
678
- )}
455
+ {Api.getApi().sendPhotosToCRM() && (
456
+ <UploadWarningModal
457
+ visible={showInfoDialog}
458
+ onClose={onCloseInfoDialog}
459
+ />
460
+ )}
461
+ </ScreenSafeAreaView>
679
462
  </Modal>
680
- </>
463
+ )
464
+ }
465
+
466
+ return (
467
+ <MultiImagePicker ref={setPickerRef} hitSlop={hitSlop} maxCount={maxCount} parentStyle={parentStyle} callback={onImageSelect}>
468
+ {children}
469
+ </MultiImagePicker>
681
470
  )
682
471
  })
683
472
 
@@ -1,5 +1,5 @@
1
1
  import React, { useCallback, useState } from 'react'
2
- import { Modal, View, StyleSheet, Text, Platform } from 'react-native'
2
+ import { View, StyleSheet, Text, Platform } from 'react-native'
3
3
  import { colors, stdStyles } from '@supportworks/app-styler'
4
4
  import { CheckBox, CommonButton } from '@supportworks/core-controls'
5
5
  import { Icons } from '@supportworks/icon-library'
@@ -15,53 +15,56 @@ const UploadWarningModal = (
15
15
  if (onClose) onClose(skipInfoDialog)
16
16
  }, [onClose, skipInfoDialog])
17
17
 
18
+ if (!visible) {
19
+ return null
20
+ }
21
+
18
22
  return (
19
- <Modal
20
- animationType='fade'
21
- transparent
22
- visible={visible}
23
- onRequestClose={handleClose}
24
- >
25
- <View style={styles.ModalView}>
26
- <View style={styles.InfoDialogContent}>
27
- <View style={styles.InfoDialogIconRow}>
28
- <Icons.IconPencilLock fill={colors.brandPrimary} fillOpacity={1} />
29
- </View>
30
- <View style={styles.InfoDialogTitleRow}>
31
- <Text style={styles.TitleText}>
32
- Captions can't be updated in CRM after upload
33
- </Text>
34
- </View>
35
- <Text style={stdStyles.Body2}>
36
- Photo captions can be edited now, but not after submitting to the CRM. Please review before uploading.
23
+ <View style={styles.ModalView}>
24
+ <View style={styles.Backdrop} />
25
+ <View style={styles.InfoDialogContent}>
26
+ <View style={styles.InfoDialogIconRow}>
27
+ <Icons.IconPencilLock fill={colors.brandPrimary} fillOpacity={1} />
28
+ </View>
29
+ <View style={styles.InfoDialogTitleRow}>
30
+ <Text style={styles.TitleText}>
31
+ Captions can't be updated in CRM after upload
37
32
  </Text>
38
- <View style={styles.InfoDialogCheckboxRow}>
39
- <CheckBox
40
- label="Don't show this message again"
41
- checked={!!skipInfoDialog}
42
- onChange={(newVal) => setSkipInfoDialog(newVal)}
43
- />
44
- </View>
45
- <View style={styles.InfoDialogButtonRow}>
46
- <CommonButton
47
- variant='filled'
48
- size='medium'
49
- label='Got it'
50
- fullWidth
51
- onPress={handleClose}
52
- />
53
- </View>
33
+ </View>
34
+ <Text style={stdStyles.Body2}>
35
+ Photo captions can be edited now, but not after submitting to the CRM. Please review before uploading.
36
+ </Text>
37
+ <View style={styles.InfoDialogCheckboxRow}>
38
+ <CheckBox
39
+ label="Don't show this message again"
40
+ checked={!!skipInfoDialog}
41
+ onChange={(newVal) => setSkipInfoDialog(newVal)}
42
+ />
43
+ </View>
44
+ <View style={styles.InfoDialogButtonRow}>
45
+ <CommonButton
46
+ variant='filled'
47
+ size='medium'
48
+ label='Got it'
49
+ fullWidth
50
+ onPress={handleClose}
51
+ />
54
52
  </View>
55
53
  </View>
56
- </Modal>
54
+ </View>
57
55
  )
58
56
  }
59
57
 
60
58
  const styles = StyleSheet.create({
61
59
  ModalView: {
62
- flex: 1,
60
+ ...StyleSheet.absoluteFillObject,
63
61
  justifyContent: 'center',
64
62
  alignItems: 'center',
63
+ zIndex: 10
64
+ },
65
+ Backdrop: {
66
+ ...StyleSheet.absoluteFillObject,
67
+ backgroundColor: colors.black36
65
68
  },
66
69
  InfoDialogContent: {
67
70
  backgroundColor: 'white',