react-native-boxes 1.4.39 → 1.4.40

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/Modal.tsx +40 -18
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-boxes",
3
- "version": "1.4.39",
3
+ "version": "1.4.40",
4
4
  "description": "A react native library for rapid development of UI using boxes",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
package/src/Modal.tsx CHANGED
@@ -380,6 +380,7 @@ export type DropDownViewProps = {
380
380
  title?: string,
381
381
  displayType?: 'button' | 'input',
382
382
  onRenderOption?: (opt: DropDownViewOption, setSelected: (selectedId: string, opt: DropDownViewOption) => void) => any,
383
+ onEmptyListPlaceholder?: (dismiss?: () => void) => React.ReactNode
383
384
  forceDialogSelectOnWeb?: Boolean
384
385
  swipeToCloseDisabled?: boolean
385
386
  } & CompositeTextInputViewProps
@@ -405,6 +406,11 @@ export const DropDownView = (props: DropDownViewProps) => {
405
406
  }
406
407
  const shouldShowLabel = props.listType == 'horizontal-list' ? !visible : true
407
408
  if (Platform.OS == 'web' && !props.forceDialogSelectOnWeb) {
409
+ if (props.options?.length == 0) {
410
+ if (props.onEmptyListPlaceholder) {
411
+ return props.onEmptyListPlaceholder()
412
+ }
413
+ }
408
414
  return (
409
415
  <>
410
416
  <select
@@ -452,6 +458,11 @@ export const DropDownView = (props: DropDownViewProps) => {
452
458
  )
453
459
  }
454
460
  else {
461
+ if (visible && props.listType == 'horizontal-list' && props.options?.length == 0 && props.onEmptyListPlaceholder) {
462
+ return props.onEmptyListPlaceholder(() => {
463
+ setVisible(false)
464
+ })
465
+ }
455
466
  return (
456
467
  <VBox style={props.style}>
457
468
 
@@ -521,25 +532,37 @@ export const DropDownView = (props: DropDownViewProps) => {
521
532
  setVisible(false)
522
533
  }}
523
534
  title={props.title || ''} >
535
+
524
536
  {
525
- props.options.map((opt, idx) => {
526
- if (props.onRenderOption) {
527
- return props.onRenderOption(opt, onSelect)
528
- }
529
- return (
530
- <TertiaryButtonView
531
- onPress={() => {
532
- setVisible(false)
533
- props.onSelect(opt.id, opt)
534
- }}
535
- style={{
536
- padding: 0,
537
- paddingBottom: idx == props.options.length - 1 ? theme.dimens.space.md : 0,
538
- paddingTop: idx == 0 ? theme.dimens.space.md : 0,
539
- }}
540
- key={opt.id} >{opt.title || opt.value}</TertiaryButtonView>
537
+ props.options?.length == 0 && props.onEmptyListPlaceholder ?
538
+ (
539
+ props.onEmptyListPlaceholder(() => {
540
+ setVisible(false)
541
+ })
541
542
  )
542
- })
543
+ :
544
+ (
545
+
546
+ props.options.map((opt, idx) => {
547
+ if (props.onRenderOption) {
548
+ return props.onRenderOption(opt, onSelect)
549
+ }
550
+ return (
551
+ <TertiaryButtonView
552
+ onPress={() => {
553
+ setVisible(false)
554
+ props.onSelect(opt.id, opt)
555
+ }}
556
+ style={{
557
+ padding: 0,
558
+ paddingBottom: idx == props.options.length - 1 ? theme.dimens.space.md : 0,
559
+ paddingTop: idx == 0 ? theme.dimens.space.md : 0,
560
+ }}
561
+ key={opt.id} >{opt.title || opt.value}</TertiaryButtonView>
562
+ )
563
+ })
564
+ )
565
+
543
566
  }
544
567
  </BottomSheet>
545
568
  )
@@ -594,7 +617,6 @@ export const DropDownView = (props: DropDownViewProps) => {
594
617
  }
595
618
 
596
619
 
597
-
598
620
  export type ConfirmationDialogProps = {
599
621
  visible: boolean,
600
622
  title?: string | React.Component,