react-crud-mobile 1.3.46 → 1.3.47

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.
@@ -1,6 +1,6 @@
1
- import React, { useState, useEffect, useRef, useContext, useLayoutEffect, createContext } from 'react';
1
+ import React, { useState, useRef, useEffect, useContext, useLayoutEffect, createContext } from 'react';
2
2
  import { Utils, ScopeUtils, CrudUtils, ComponentUtils, ViewUtils, HtmlUtils, ThemeUtils, useTheme } from 'react-crud-utils';
3
- import { View, StyleSheet, TouchableOpacity, Text, Linking, TouchableHighlight, Switch, TextInput, Platform, Dimensions, Modal, SafeAreaView, ScrollView, Alert, Image, StatusBar, KeyboardAvoidingView, TouchableWithoutFeedback, Keyboard } from 'react-native';
3
+ import { View, StyleSheet, TouchableOpacity, Text, Linking, TouchableHighlight, Modal, SafeAreaView, ScrollView, Switch, TextInput, Platform, Dimensions, Alert, Image, StatusBar, KeyboardAvoidingView, TouchableWithoutFeedback, Keyboard } from 'react-native';
4
4
  import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
5
5
  import Ionicons from '@expo/vector-icons/Ionicons';
6
6
  import { Ionicons as Ionicons$1, AntDesign, Entypo, EvilIcons, MaterialCommunityIcons } from '@expo/vector-icons';
@@ -481,8 +481,25 @@ function UIButton(props) {
481
481
  });
482
482
  }
483
483
 
484
+ //import { ThemeUtils, Utils } from 'react-crud-utils';
485
+ //import { StatusBar } from 'react-native';
486
+ var MobileUtils = /*#__PURE__*/function () {
487
+ function MobileUtils() {}
488
+ MobileUtils.syncTheme = function syncTheme() {
489
+ // let current = ThemeUtils.getCurrentTheme();
490
+ //let dec: any = { light: 'light-content', dark: 'dark-content' };
491
+ //let name = Utils.nvl(dec[current?.theme], dec.light);
492
+ //StatusBar.setBarStyle?.(name);
493
+ //StatusBar.setBackgroundColor?.(current?.colors?.theme);
494
+ };
495
+ return MobileUtils;
496
+ }();
497
+
484
498
  function UISelect(props) {
485
- var _theme$styles, _theme$colors, _scope$original, _scope$original2;
499
+ var _theme$styles, _theme$colors, _scope$original, _scope$original2, _scope$original3, _scope$original4;
500
+ var _useState = useState(false),
501
+ modalVisible = _useState[0],
502
+ setModalVisible = _useState[1];
486
503
  var scope = props.scope;
487
504
  var element = scope.original;
488
505
  var items = Utils.nvl(scope.getOptions(), []);
@@ -490,17 +507,15 @@ function UISelect(props) {
490
507
  var value = scope.getDisplayValue();
491
508
  var theme = scope.getTheme();
492
509
  var headerStyle = Utils.nvl((_theme$styles = theme.styles) == null || (_theme$styles = _theme$styles.defaults) == null ? void 0 : _theme$styles.header, {});
493
- var dlgName = scope.getName('dialog');
494
510
  var handlePress = function handlePress() {
495
- scope.call('click', {
496
- click: {
497
- action: 'dialog',
498
- dialog: dlgName
499
- }
500
- });
511
+ setModalVisible(!modalVisible);
501
512
  };
513
+ var scrollRef = useRef(null);
502
514
  var iconColor = Utils.nvl((_theme$colors = theme.colors) == null ? void 0 : _theme$colors.text, '#100e0e');
503
515
  var modalColor = Utils.nvl(headerStyle.color, 'white');
516
+ var defaults = {
517
+ color: modalColor
518
+ };
504
519
  var onClick = function onClick(_ref) {
505
520
  var value = _ref.value;
506
521
  var val = value;
@@ -511,11 +526,19 @@ function UISelect(props) {
511
526
  } else {
512
527
  scope.changeValue(value);
513
528
  }
529
+ setModalVisible(false);
514
530
  };
515
531
  var style = function style(part, extra) {
516
532
  var all = _extends({}, styles$3[part], extra);
517
533
  return scope.getStyle(part, all);
518
534
  };
535
+ var isModalVisible = function isModalVisible() {
536
+ return modalVisible;
537
+ };
538
+ //v4
539
+ useEffect(function () {
540
+ MobileUtils.syncTheme();
541
+ }, [modalVisible]);
519
542
  return /*#__PURE__*/jsxs(View, {
520
543
  style: style('selectRoot'),
521
544
  children: [/*#__PURE__*/jsxs(TouchableOpacity, {
@@ -530,25 +553,101 @@ function UISelect(props) {
530
553
  color: scope.getPart('iconColor', null, iconColor),
531
554
  style: style('iconStyle', {})
532
555
  })]
533
- }), /*#__PURE__*/jsx(UI.Dialog, {
534
- name: dlgName,
535
- label: "Selecione",
536
- children: /*#__PURE__*/jsx(UI.List, _extends({
537
- data: items,
538
- name: scope.getName('list'),
539
- layout: "card",
540
- click: onClick,
541
- rowStyle: _extends({
542
- paddingLeft: 15,
543
- paddinRight: 15
544
- }, (_scope$original = scope.original) == null ? void 0 : _scope$original.rowStyle)
545
- }, (_scope$original2 = scope.original) == null ? void 0 : _scope$original2.listProps, {
546
- children: /*#__PURE__*/jsx(UI.Value, {
547
- value: "#{@this.label}"
548
- })
549
- }))
556
+ }), /*#__PURE__*/jsxs(Modal, {
557
+ animationType: "slide",
558
+ transparent: true,
559
+ visible: isModalVisible(),
560
+ onRequestClose: function onRequestClose() {
561
+ return setModalVisible(false);
562
+ },
563
+ children: [/*#__PURE__*/jsx(SafeAreaView, {
564
+ style: style('modalTop')
565
+ }), /*#__PURE__*/jsxs(SafeAreaView, {
566
+ style: style('modalSafe'),
567
+ children: [/*#__PURE__*/jsxs(View, {
568
+ style: scope.getStyle('header', headerStyle),
569
+ children: [/*#__PURE__*/jsx(TouchableOpacity, {
570
+ onPress: handlePress,
571
+ style: style('modalCloseButton'),
572
+ children: /*#__PURE__*/jsx(Ionicons$1, {
573
+ name: "close",
574
+ size: 24,
575
+ color: modalColor,
576
+ style: style('modalCloseText', defaults)
577
+ })
578
+ }), /*#__PURE__*/jsx(Text, {
579
+ style: style('modalTitle', defaults),
580
+ children: placeholder
581
+ })]
582
+ }), /*#__PURE__*/jsx(ScrollView, {
583
+ contentContainerStyle: {
584
+ flexGrow: 1,
585
+ paddingBottom: 50
586
+ },
587
+ style: style('modalContent'),
588
+ nestedScrollEnabled: true,
589
+ ref: scrollRef,
590
+ children: /*#__PURE__*/jsx(View, {
591
+ style: {
592
+ flex: 1
593
+ },
594
+ children: /*#__PURE__*/jsx(UI.List, _extends({
595
+ data: items,
596
+ name: scope.getName('list'),
597
+ layout: "card",
598
+ click: onClick,
599
+ rowStyle: _extends({
600
+ paddingLeft: 15,
601
+ paddinRight: 15
602
+ }, (_scope$original = scope.original) == null ? void 0 : _scope$original.rowStyle)
603
+ }, (_scope$original2 = scope.original) == null ? void 0 : _scope$original2.listProps, {
604
+ children: /*#__PURE__*/jsx(UI.Value, {
605
+ value: "#{@this.label}"
606
+ })
607
+ }))
608
+ })
609
+ })]
610
+ }), /*#__PURE__*/jsx(SafeAreaView, {
611
+ style: style('modalTop')
612
+ }), /*#__PURE__*/jsxs(SafeAreaView, {
613
+ style: style('modalSafe'),
614
+ children: [/*#__PURE__*/jsxs(View, {
615
+ style: scope.getStyle('header', headerStyle),
616
+ children: [/*#__PURE__*/jsx(TouchableOpacity, {
617
+ onPress: function onPress() {
618
+ return setModalVisible(false);
619
+ },
620
+ style: style('modalCloseButton'),
621
+ children: /*#__PURE__*/jsx(Ionicons$1, {
622
+ name: "close",
623
+ size: 24,
624
+ color: modalColor,
625
+ style: style('modalCloseText', defaults)
626
+ })
627
+ }), /*#__PURE__*/jsx(Text, {
628
+ style: style('modalTitle'),
629
+ children: placeholder
630
+ })]
631
+ }), /*#__PURE__*/jsx(View, {
632
+ style: style('modalContent'),
633
+ children: /*#__PURE__*/jsx(UI.List, _extends({
634
+ data: items,
635
+ name: scope.getName('list'),
636
+ layout: "card",
637
+ click: onClick,
638
+ rowStyle: _extends({
639
+ paddingLeft: 15,
640
+ paddinRight: 15
641
+ }, (_scope$original3 = scope.original) == null ? void 0 : _scope$original3.rowStyle)
642
+ }, (_scope$original4 = scope.original) == null ? void 0 : _scope$original4.listProps, {
643
+ children: /*#__PURE__*/jsx(UI.Value, {
644
+ value: "#{@this.label}"
645
+ })
646
+ }))
647
+ })]
648
+ })]
550
649
  })]
551
- }, scope.getName("" + scope.getPart('modal')));
650
+ }, scope.getName(scope.getPart('modal') + "_" + modalVisible));
552
651
  }
553
652
  var styles$3 = /*#__PURE__*/StyleSheet.create({
554
653
  selectRoot: {
@@ -1450,20 +1549,6 @@ var styles$8 = /*#__PURE__*/StyleSheet.create({
1450
1549
  }
1451
1550
  });
1452
1551
 
1453
- //import { ThemeUtils, Utils } from 'react-crud-utils';
1454
- //import { StatusBar } from 'react-native';
1455
- var MobileUtils = /*#__PURE__*/function () {
1456
- function MobileUtils() {}
1457
- MobileUtils.syncTheme = function syncTheme() {
1458
- // let current = ThemeUtils.getCurrentTheme();
1459
- //let dec: any = { light: 'light-content', dark: 'dark-content' };
1460
- //let name = Utils.nvl(dec[current?.theme], dec.light);
1461
- //StatusBar.setBarStyle?.(name);
1462
- //StatusBar.setBackgroundColor?.(current?.colors?.theme);
1463
- };
1464
- return MobileUtils;
1465
- }();
1466
-
1467
1552
  function UIView(_ref) {
1468
1553
  var _theme$styles, _theme$styles2;
1469
1554
  var scope = _ref.scope,