@supportworks/multi-imagepicker 8.2.0 → 8.2.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/changes.md CHANGED
@@ -1,4 +1,7 @@
1
1
 
2
+ # v8.2.1 2026-04-10
3
+ * temporary attempt to fix multiple nested modals issue on older iPads
4
+
2
5
  # v8.2.0 2026-04-09
3
6
  * reverted back to v8.0.16
4
7
  * then changed UploadWarningModal to just be a regular component instead of a modal, to fix multiple nested modals issue on older iPads
package/index.js CHANGED
@@ -6,11 +6,13 @@ import ImageIndicators from './src/components/ImageIndicators'
6
6
  import ActionBar from './src/components/ActionBar'
7
7
  import ImageDetailsModal from './src/components/ImageDetailsModal'
8
8
  import CameraModal from './src/components/CameraModal'
9
+ import AddImagesView from './src/components/AddImagesView'
9
10
 
10
11
  export {
11
12
  MultiImagePicker,
12
13
  SelectedImages,
13
14
  AddImages,
15
+ AddImagesView,
14
16
  MIPickerApi,
15
17
  ImageIndicators,
16
18
  ActionBar,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@supportworks/multi-imagepicker",
3
- "version": "8.2.0",
3
+ "version": "8.2.1",
4
4
  "description": "Android and iOS customized multiple image picker. For react-native >= 0.60.",
5
5
  "main": "index.js",
6
6
  "author": {
@@ -1,22 +1,17 @@
1
1
  import React, { useCallback, useEffect, useState, useRef, forwardRef, useImperativeHandle } from 'react'
2
2
  import {
3
3
  View,
4
- Modal,
5
- StyleSheet, ScrollView, KeyboardAvoidingView, Platform, PermissionsAndroid, Alert
4
+ StyleSheet, Platform, PermissionsAndroid, Alert
6
5
  } from 'react-native'
7
6
  import Moment from 'moment'
8
- import { Icons } from '@supportworks/icon-library'
9
7
  import loaderHandler from './loaderHandler'
10
8
  import MultiImagePicker from './MultiImagePicker'
11
- import SelectedImages from './SelectedImages'
12
- import { colors } from '@supportworks/app-styler'
13
9
  import { LoadingOverlay } from '@supportworks/navbars'
14
- import { CheckBox, AppBarH8, CommonButton, ListItem, ScreenSafeAreaView } from '@supportworks/core-controls'
15
10
  import { CameraRoll } from '@react-native-camera-roll/camera-roll'
16
11
  import { Api } from '@supportworks/api-core'
17
12
  import { Analytics } from '@supportworks/analytics'
18
13
  import AsyncStorage from '@react-native-async-storage/async-storage'
19
- import UploadWarningModal from './UploadWarningModal'
14
+ import AddImagesView from './AddImagesView'
20
15
 
21
16
  const AddImages = forwardRef((
22
17
  {
@@ -28,6 +23,8 @@ const AddImages = forwardRef((
28
23
  allowEdit = true, // whether to allow user to edit file names and descriptions
29
24
  annotationAllowed = false, // whether to allow annotations on images
30
25
  showToCustomerAllowed = false, // whether to allow "show to customer" option
26
+ renderInlineEditor = true, // backward-compatible inline editor rendering; disable to mount AddImagesView elsewhere
27
+ onEditorStateChange = null, // optional callback for externally mounting AddImagesView in a caller-controlled full-screen container
31
28
  maxCount, // = null, //max number of images that can be selected. Passed to MultiImagePicker. If null default not commented out, causes crash, so leave it this way.
32
29
  children
33
30
  }, ref) => {
@@ -46,6 +43,14 @@ const AddImages = forwardRef((
46
43
  const imgSourceRef = useRef(null) // temp value designating picker type used, if image was "taken" from device now, or image(s) chosen from "library"
47
44
  const pickerRef = useRef(null)
48
45
  const isMountedRef = useRef(true)
46
+ const onCloseRef = useRef(null)
47
+ const onAttachRef = useRef(null)
48
+ const onDeleteItemRef = useRef(null)
49
+ const onItemChangeRef = useRef(null)
50
+ const onCloseInfoDialogRef = useRef(null)
51
+ const onValidateRef = useRef(null)
52
+ const onPressCheckboxShowToCustRef = useRef(null)
53
+ const onPressCheckboxSaveToDeviceRef = useRef(null)
49
54
  const STORAGE_KEY_SKIP_DIALOG = '@MIP_UploadWarningsModal_Skip'
50
55
  const allowSaveToDevicePlatform = Platform.OS !== 'android' // TODO: set to true when Android support is added
51
56
 
@@ -341,166 +346,117 @@ const AddImages = forwardRef((
341
346
  }
342
347
  }, [allowEdit, buildDefaultFilename, onAttach, showToCustomerAllowed])
343
348
 
344
- const SaveOptions = () => {
345
- if (!showToCustomerAllowed && !allowSaveToDevice) {
346
- return null
347
- }
348
- const total = items.length
349
- const saveCount = items.filter(i => !!i.saveToDevice).length
350
- const showCount = items.filter(i => !!i.showToCust).length
351
- const allSave = total > 0 && saveCount === total
352
- const someSave = total > 0 && saveCount > 0 && saveCount < total
353
- const allShow = total > 0 && showCount === total
354
- const someShow = total > 0 && showCount > 0 && showCount < total
355
- // console.log(`SaveOptions: total=${total}, saveCount=${saveCount}, showCount=${showCount}, allSave=${allSave}, someSave=${someSave}, allShow=${allShow}, someShow=${someShow}`)
356
-
357
- return (
358
- <View style={styles.SaveOptionsContainer}>
359
- {showToCustomerAllowed
360
- ? <ListItem
361
- key='showToCust'
362
- leftContent={
363
- <View style={styles.IconCircle}>
364
- <Icons.IconEye_WithPad fill={colors.buttonPrimary} fillOpacity={1} />
365
- </View>
366
- }
367
- mainAction={onPressCheckbox_ShowToCust}
368
- rightAction={onPressCheckbox_ShowToCust}
369
- title='Show all to customer'
370
- subtitle='Select to share all w/ customer.'
371
- rightContent={<CheckBox
372
- checked={allShow}
373
- indeterminate={someShow}
374
- onChange={onPressCheckbox_ShowToCust}
375
- />}
376
- height={55}
377
- paddingLeft={20}
378
- rightContentWidth={40}
379
- paddingRight={16}
380
- topSeparator={false}
381
- />
382
- : null}
383
- {allowSaveToDevice
384
- ? <ListItem
385
- key='saveToDevice'
386
- leftContent={
387
- <View style={styles.IconCircle}>
388
- <Icons.IconSave_WithPad fill={colors.buttonPrimary} fillOpacity={1} />
389
- </View>
390
- }
391
- mainAction={onPressCheckbox_SaveToDevice}
392
- rightAction={onPressCheckbox_SaveToDevice}
393
- title='Download all to device'
394
- rightContent={<CheckBox
395
- checked={allSave}
396
- indeterminate={someSave}
397
- onChange={onPressCheckbox_SaveToDevice}
398
- />}
399
- height={56}
400
- paddingLeft={20}
401
- rightContentWidth={40}
402
- paddingRight={16}
403
- topSeparator={showToCustomerAllowed}
404
- />
405
- : null}
406
- </View>
407
- )
408
- }
349
+ const addImagesEditor = (
350
+ <View style={styles.Overlay}>
351
+ <AddImagesView
352
+ items={items}
353
+ annotationAllowed={annotationAllowed}
354
+ showToCustomerAllowed={showToCustomerAllowed}
355
+ allowSaveToDevice={allowSaveToDevice}
356
+ allImageDataValid={allImageDataValid}
357
+ showInfoDialog={showInfoDialog}
358
+ onClose={onClose}
359
+ onAttach={onAttach}
360
+ onDeleteItem={handleDeleteItem}
361
+ onItemChange={onItemChange}
362
+ onCloseInfoDialog={onCloseInfoDialog}
363
+ onValidate={handleSetAllImageDataValid}
364
+ onPressCheckboxShowToCust={onPressCheckbox_ShowToCust}
365
+ onPressCheckboxSaveToDevice={onPressCheckbox_SaveToDevice}
366
+ />
367
+ </View>
368
+ )
409
369
 
410
- if (showAttaching) {
411
- return (
412
- <LoadingOverlay />
413
- )
414
- }
370
+ useEffect(() => {
371
+ onCloseRef.current = onClose
372
+ onAttachRef.current = onAttach
373
+ onDeleteItemRef.current = handleDeleteItem
374
+ onItemChangeRef.current = onItemChange
375
+ onCloseInfoDialogRef.current = onCloseInfoDialog
376
+ onValidateRef.current = handleSetAllImageDataValid
377
+ onPressCheckboxShowToCustRef.current = onPressCheckbox_ShowToCust
378
+ onPressCheckboxSaveToDeviceRef.current = onPressCheckbox_SaveToDevice
379
+ }, [
380
+ handleDeleteItem,
381
+ handleSetAllImageDataValid,
382
+ onAttach,
383
+ onClose,
384
+ onCloseInfoDialog,
385
+ onItemChange,
386
+ onPressCheckbox_SaveToDevice,
387
+ onPressCheckbox_ShowToCust
388
+ ])
389
+
390
+ const externalOnClose = useCallback((...args) => onCloseRef.current?.(...args), [])
391
+ const externalOnAttach = useCallback((...args) => onAttachRef.current?.(...args), [])
392
+ const externalOnDeleteItem = useCallback((...args) => onDeleteItemRef.current?.(...args), [])
393
+ const externalOnItemChange = useCallback((...args) => onItemChangeRef.current?.(...args), [])
394
+ const externalOnCloseInfoDialog = useCallback((...args) => onCloseInfoDialogRef.current?.(...args), [])
395
+ const externalOnValidate = useCallback((...args) => onValidateRef.current?.(...args), [])
396
+ const externalOnPressCheckboxShowToCust = useCallback((...args) => onPressCheckboxShowToCustRef.current?.(...args), [])
397
+ const externalOnPressCheckboxSaveToDevice = useCallback((...args) => onPressCheckboxSaveToDeviceRef.current?.(...args), [])
415
398
 
416
- if (showAdd) {
417
- return (
418
- <Modal presentationStyle='fullScreen' animationType='slide'>
419
- <ScreenSafeAreaView style={styles.Page} edges={['top','bottom']} includeProvider>
420
- <AppBarH8
421
- variant='regular'
422
- title='Photos to Add'
423
- subtitle={items.length + ' Photo' + (items.length > 1 ? 's' : '')}
424
- leftContentType='closeButton'
425
- callback={onClose}
426
- bgColor={colors.backgroundMedium}
427
- bottomShadow
428
- />
429
- <SaveOptions />
430
- <KeyboardAvoidingView behavior='padding' enabled style={styles.Content}>
431
- <ScrollView contentContainerStyle={styles.ScrollViewContainer} keyboardShouldPersistTaps='handled'>
432
- <SelectedImages
433
- items={items}
434
- callback={handleSetAllImageDataValid}
435
- annotationAllowed={annotationAllowed}
436
- onDeleteItem={handleDeleteItem}
437
- onItemChange={onItemChange}
438
- allowSaveToDevice={allowSaveToDevice}
439
- allowShowToCustomer={showToCustomerAllowed}
440
- />
441
- </ScrollView>
442
- </KeyboardAvoidingView>
443
- <View style={styles.ButtonContainer}>
444
- <CommonButton
445
- variant='filled'
446
- size='medium'
447
- fullWidth
448
- label='Attach'
449
- endIcon={<Icons.IconUploadAll />}
450
- onPress={onAttach}
451
- disabled={!allImageDataValid}
452
- />
453
- </View>
454
-
455
- {Api.getApi().sendPhotosToCRM() && (
456
- <UploadWarningModal
457
- visible={showInfoDialog}
458
- onClose={onCloseInfoDialog}
459
- />
460
- )}
461
- </ScreenSafeAreaView>
462
- </Modal>
463
- )
464
- }
399
+ useEffect(() => {
400
+ if (typeof onEditorStateChange !== 'function') {
401
+ return
402
+ }
403
+
404
+ onEditorStateChange({
405
+ visible: showAdd,
406
+ attaching: showAttaching,
407
+ editorProps: {
408
+ items,
409
+ annotationAllowed,
410
+ showToCustomerAllowed,
411
+ allowSaveToDevice,
412
+ allImageDataValid,
413
+ showInfoDialog,
414
+ onClose: externalOnClose,
415
+ onAttach: externalOnAttach,
416
+ onDeleteItem: externalOnDeleteItem,
417
+ onItemChange: externalOnItemChange,
418
+ onCloseInfoDialog: externalOnCloseInfoDialog,
419
+ onValidate: externalOnValidate,
420
+ onPressCheckboxShowToCust: externalOnPressCheckboxShowToCust,
421
+ onPressCheckboxSaveToDevice: externalOnPressCheckboxSaveToDevice
422
+ }
423
+ })
424
+ }, [
425
+ allowSaveToDevice,
426
+ allImageDataValid,
427
+ annotationAllowed,
428
+ externalOnAttach,
429
+ externalOnClose,
430
+ externalOnCloseInfoDialog,
431
+ externalOnDeleteItem,
432
+ externalOnItemChange,
433
+ externalOnPressCheckboxSaveToDevice,
434
+ externalOnPressCheckboxShowToCust,
435
+ externalOnValidate,
436
+ items,
437
+ onEditorStateChange,
438
+ showAdd,
439
+ showAttaching,
440
+ showInfoDialog,
441
+ showToCustomerAllowed
442
+ ])
465
443
 
466
444
  return (
467
- <MultiImagePicker ref={setPickerRef} hitSlop={hitSlop} maxCount={maxCount} parentStyle={parentStyle} callback={onImageSelect}>
468
- {children}
469
- </MultiImagePicker>
445
+ <>
446
+ {!showAdd && !showAttaching && <MultiImagePicker ref={setPickerRef} hitSlop={hitSlop} maxCount={maxCount} parentStyle={parentStyle} callback={onImageSelect}>
447
+ {children}
448
+ </MultiImagePicker>}
449
+ {renderInlineEditor && showAdd && addImagesEditor}
450
+ {renderInlineEditor && showAttaching && <LoadingOverlay />}
451
+ </>
470
452
  )
471
453
  })
472
454
 
473
455
  const styles = StyleSheet.create({
474
- Page: {
475
- backgroundColor: colors.backgroundMedium,
476
- flex: 1
477
- },
478
- Content: {
479
- flex: 1
480
- },
481
- ScrollViewContainer: {
482
- paddingBottom: 100,
483
- marginTop: 8
484
- },
485
- SaveOptionsContainer: {
486
- backgroundColor: colors.white,
487
- margin: 16,
488
- borderRadius: 16
489
- },
490
- IconCircle: {
491
- width: 32,
492
- height: 32,
493
- borderRadius: 16,
494
- backgroundColor: colors.buttonPrimaryLight,
495
- justifyContent: 'center',
496
- alignItems: 'center'
497
- },
498
- ButtonContainer: {
499
- height: 56,
500
- paddingHorizontal: 16,
501
- paddingVertical: 8,
502
- borderTopWidth: 1,
503
- borderTopColor: colors.black05
456
+ Overlay: {
457
+ ...StyleSheet.absoluteFillObject,
458
+ zIndex: 1000,
459
+ elevation: 1000
504
460
  }
505
461
  })
506
462
 
@@ -0,0 +1,173 @@
1
+ import React from 'react'
2
+ import { View, StyleSheet, ScrollView, KeyboardAvoidingView } from 'react-native'
3
+ import { Icons } from '@supportworks/icon-library'
4
+ import SelectedImages from './SelectedImages'
5
+ import { colors } from '@supportworks/app-styler'
6
+ import { CheckBox, AppBarH8, CommonButton, ListItem, ScreenSafeAreaView } from '@supportworks/core-controls'
7
+ import { Api } from '@supportworks/api-core'
8
+ import UploadWarningModal from './UploadWarningModal'
9
+
10
+ const AddImagesView = ({
11
+ items = [],
12
+ annotationAllowed = false,
13
+ showToCustomerAllowed = false,
14
+ allowSaveToDevice = false,
15
+ allImageDataValid = true,
16
+ showInfoDialog = false,
17
+ onClose = null,
18
+ onAttach = null,
19
+ onDeleteItem = null,
20
+ onItemChange = null,
21
+ onCloseInfoDialog = null,
22
+ onValidate = null,
23
+ onPressCheckboxShowToCust = null,
24
+ onPressCheckboxSaveToDevice = null
25
+ }) => {
26
+ const SaveOptions = () => {
27
+ if (!showToCustomerAllowed && !allowSaveToDevice) {
28
+ return null
29
+ }
30
+
31
+ const total = items.length
32
+ const saveCount = items.filter(i => !!i.saveToDevice).length
33
+ const showCount = items.filter(i => !!i.showToCust).length
34
+ const allSave = total > 0 && saveCount === total
35
+ const someSave = total > 0 && saveCount > 0 && saveCount < total
36
+ const allShow = total > 0 && showCount === total
37
+ const someShow = total > 0 && showCount > 0 && showCount < total
38
+
39
+ return (
40
+ <View style={styles.SaveOptionsContainer}>
41
+ {showToCustomerAllowed
42
+ ? <ListItem
43
+ key='showToCust'
44
+ leftContent={
45
+ <View style={styles.IconCircle}>
46
+ <Icons.IconEye_WithPad fill={colors.buttonPrimary} fillOpacity={1} />
47
+ </View>
48
+ }
49
+ mainAction={onPressCheckboxShowToCust}
50
+ rightAction={onPressCheckboxShowToCust}
51
+ title='Show all to customer'
52
+ subtitle='Select to share all w/ customer.'
53
+ rightContent={<CheckBox
54
+ checked={allShow}
55
+ indeterminate={someShow}
56
+ onChange={onPressCheckboxShowToCust}
57
+ />}
58
+ height={55}
59
+ paddingLeft={20}
60
+ rightContentWidth={40}
61
+ paddingRight={16}
62
+ topSeparator={false}
63
+ />
64
+ : null}
65
+ {allowSaveToDevice
66
+ ? <ListItem
67
+ key='saveToDevice'
68
+ leftContent={
69
+ <View style={styles.IconCircle}>
70
+ <Icons.IconSave_WithPad fill={colors.buttonPrimary} fillOpacity={1} />
71
+ </View>
72
+ }
73
+ mainAction={onPressCheckboxSaveToDevice}
74
+ rightAction={onPressCheckboxSaveToDevice}
75
+ title='Download all to device'
76
+ rightContent={<CheckBox
77
+ checked={allSave}
78
+ indeterminate={someSave}
79
+ onChange={onPressCheckboxSaveToDevice}
80
+ />}
81
+ height={56}
82
+ paddingLeft={20}
83
+ rightContentWidth={40}
84
+ paddingRight={16}
85
+ topSeparator={showToCustomerAllowed}
86
+ />
87
+ : null}
88
+ </View>
89
+ )
90
+ }
91
+
92
+ return (
93
+ <ScreenSafeAreaView style={styles.Page} edges={['top', 'bottom']} includeProvider>
94
+ <AppBarH8
95
+ variant='regular'
96
+ title='Photos to Add'
97
+ subtitle={items.length + ' Photo' + (items.length > 1 ? 's' : '')}
98
+ leftContentType='closeButton'
99
+ callback={onClose}
100
+ bgColor={colors.backgroundMedium}
101
+ bottomShadow
102
+ />
103
+ <SaveOptions />
104
+ <KeyboardAvoidingView behavior='padding' enabled style={styles.Content}>
105
+ <ScrollView contentContainerStyle={styles.ScrollViewContainer} keyboardShouldPersistTaps='handled'>
106
+ <SelectedImages
107
+ items={items}
108
+ callback={onValidate}
109
+ annotationAllowed={annotationAllowed}
110
+ onDeleteItem={onDeleteItem}
111
+ onItemChange={onItemChange}
112
+ allowSaveToDevice={allowSaveToDevice}
113
+ allowShowToCustomer={showToCustomerAllowed}
114
+ />
115
+ </ScrollView>
116
+ </KeyboardAvoidingView>
117
+ <View style={styles.ButtonContainer}>
118
+ <CommonButton
119
+ variant='filled'
120
+ size='medium'
121
+ fullWidth
122
+ label='Attach'
123
+ endIcon={<Icons.IconUploadAll />}
124
+ onPress={onAttach}
125
+ disabled={!allImageDataValid}
126
+ />
127
+ </View>
128
+
129
+ {Api.getApi().sendPhotosToCRM() && (
130
+ <UploadWarningModal
131
+ visible={showInfoDialog}
132
+ onClose={onCloseInfoDialog}
133
+ />
134
+ )}
135
+ </ScreenSafeAreaView>
136
+ )
137
+ }
138
+
139
+ const styles = StyleSheet.create({
140
+ Page: {
141
+ backgroundColor: colors.backgroundMedium,
142
+ flex: 1
143
+ },
144
+ Content: {
145
+ flex: 1
146
+ },
147
+ ScrollViewContainer: {
148
+ paddingBottom: 100,
149
+ marginTop: 8
150
+ },
151
+ SaveOptionsContainer: {
152
+ backgroundColor: colors.white,
153
+ margin: 16,
154
+ borderRadius: 16
155
+ },
156
+ IconCircle: {
157
+ width: 32,
158
+ height: 32,
159
+ borderRadius: 16,
160
+ backgroundColor: colors.buttonPrimaryLight,
161
+ justifyContent: 'center',
162
+ alignItems: 'center'
163
+ },
164
+ ButtonContainer: {
165
+ height: 56,
166
+ paddingHorizontal: 16,
167
+ paddingVertical: 8,
168
+ borderTopWidth: 1,
169
+ borderTopColor: colors.black05
170
+ }
171
+ })
172
+
173
+ export default AddImagesView