react-crud-mobile 1.0.621 → 1.0.622

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,2 +1,2 @@
1
- "use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react"),n=e(t),r=require("react-crud-utils"),i=require("react-native"),l=require("react/jsx-runtime"),a=e(require("@expo/vector-icons/Ionicons")),o=require("@expo/vector-icons"),s=require("react-native-safe-area-context");function c(){return(c=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(null,arguments)}function u(e){var a=t.useState(r.Utils.nvl(e.scope,r.ScopeUtils.create(e)))[0],o=r.Utils.nvl(e.crud,a.crud),s=r.Utils.nvl(e.validateScope,"global"),p=r.Utils.nvl(e.part,"child");if(a.isInput())return l.jsx(l.Fragment,{});var f,g,h,x,y,m=function(e){var t=e.child;if(!t)return l.jsx(l.Fragment,{});if("string"==typeof t)return l.jsx(l.Fragment,{children:t});var n=t.type,i=c({},t.props);return delete i.children,"string"==typeof n?r.Utils.isEmpty(t.props.children)?l.jsx(n,c({},i)):l.jsx(n,c({},i,{children:l.jsx(u,c({transient:!0,validateScope:s},t.props,{scope:a,crud:o}))})):"function"==typeof n?l.jsx(n,c({validateScope:s},t.props,{parent:a,crud:o})):r.Utils.isEmpty(t.props.children)?l.jsx(l.Fragment,{}):l.jsx(u,c({validateScope:s},t.props,{scope:a,crud:o,transient:!0}))},j=function(){return l.jsx(l.Fragment,e.elements?{children:Object.entries(e.elements).map((function(e,t){return l.jsx(M,c({crud:o},e[1]))}))}:{children:n.Children.map(e.children,(function(e){return l.jsx(m,{child:e})}))})};return e.transient?l.jsx(j,{}):r.Utils.isEmpty(e.children)&&r.Utils.isEmpty(e.elements)?l.jsx(l.Fragment,{}):l.jsx(l.Fragment,{children:l.jsx(i.View,{style:(f=p,h=r.Utils.nvl(f,"root"),x=d[h],y={},r.Utils.isEmpty(e.style)||(null!=(g=e.style)&&g.push?r.Utils.each(e.style,(function(e){e&&(y=c({},y,e))})):y=c({},e.style)),c({},x,y,a.getStyle(f))),children:l.jsx(j,{})})})}var d=i.StyleSheet.create({child:{width:"100%"},inner:{width:"100%"}});function p(e){var i=e.scope,o=t.useState(0),s=o[0],d=o[1],p=i.original,f=i.getItems(),g=0,h=[],x=t.useState(null),y=x[0],m=x[1],j=function(e,t){void 0===t&&(t=!0),e&&i.execute({event:{validate:t,validateScope:p.validateScope,action:function(){i.changeValue(e.data),y=e,d(s=e.index),m(e)}}})},v=function(e){var t,n="ui-tabs-item ui-click";return(null==(t=y)?void 0:t.index)===e.index&&(n+=" ui-tab-selected"),n},b=function(e,t){var n=c({},e.props);t||(t=i.crud.data);var l=r.CrudUtils.create("tabs",{data:t,changed:t,parent:i.crud}),a=r.Utils.resolve(n,l);!1!==a.rendered&&h.push(c({},a,{child:e,element:a,original:n,index:g++,data:t}))};n.Children.map(e.children,(function(e,t){if(r.Utils.isEmpty(f))b(e,{});else for(var n in f)b(e,f[n])})),y||j(h[s],!1);var S=function(e){j(h[s+e])},w="stepper"===p.layout;return l.jsx("div",{className:i.getStyleClass("inner"),style:i.getStyle("inner"),children:l.jsxs("div",{className:"ui-tabs-content",children:[l.jsx("div",{className:"ui-tabs-items",children:h.map((function(e,t){return l.jsxs("div",{className:v(e),onClick:function(){j(e)},children:[w&&l.jsx("div",{className:"ui-tab-item-divisor"}),l.jsxs("div",{className:"ui-tab-item-inner",children:[w&&l.jsx("div",{className:"ui-step-line"}),l.jsx("div",{className:"ui-tab-item-label",children:w?e.index+1:e.label})]})]},r.Utils.key(p.id,"tab",t))}))}),y&&l.jsxs(l.Fragment,{children:[w&&l.jsx("div",{className:"ui-tabs-label",children:y.label}),l.jsx("div",{className:"ui-tabs-area",children:l.jsx(u,c({},e,{scope:i,children:y.child}))}),"stepper"===p.layout&&l.jsxs("div",{className:"ui-tabs-actions",children:[l.jsx(Y.Output,{space:6,layout:"left",children:l.jsx(Y.Include,c({},e,{transient:!0,name:"left",default:l.jsx(Y.Button,{rendered:s>0,icon:l.jsx(a,{}),click:function(){S(-1)}})}))}),l.jsx(Y.Output,{space:6,layout:"right",children:l.jsx(Y.Include,c({},e,{transient:!0,name:"right",default:l.jsx(Y.Button,{rendered:s<h.length-1,icon:l.jsx(a,{}),click:function(){S(1)}})}))})]})]})]})})}function f(e){var t=e.scope;return t.getItems(),r.Utils.asList(t.original.columns),l.jsx("div",{className:"ui-chart-data"})}function g(e){return l.jsx(i.TouchableOpacity,{onPress:function(){i.Linking.openURL("https://reactnative.dev/")},children:l.jsx(i.Text,{style:h.link,children:"Clique aqui para acessar o React Native"})})}var h={link:{}};function x(e){return l.jsx(l.Fragment,{children:l.jsx(g,c({},e.defaultsInput,e.defaultsUI))})}function y(e){return l.jsx(i.TouchableOpacity,{onPress:function(){i.Linking.openURL("https://reactnative.dev/")},children:l.jsx(i.Text,{style:m.link,children:"Clique aqui para acessar o React Native"})})}var m={link:{}};function j(e){var t=e.scope,n=t.getValue();return l.jsx(o.Ionicons,{name:n,style:t.getStyle("icon")})}function v(e){var t=e.scope,n=t.original,r=n.color,a=n.label,s=n.icon;r||(r="primaryLight");var u={buttonLabel:{color:"#ffffff",fontWeight:"500",fontSize:16,paddingRight:10,paddingLeft:10},buttonInner:{flexDirection:"row",alignItems:"center",justifyContent:"center",height:44,minWidth:44},buttonIcon:{color:"#fff",fontSize:18},button:{alignItems:"center",margin:"auto",width:"100%",textAlign:"center",verticalAling:"middle",borderRadius:24,backgroundColor:r,color:"#ffffff",justifyContent:"center",flex:1}},d=function(e,n){var r=c({},u[e],n);return t.getStyle(e,r)},p={};return a?s&&(p.button={padding:0,paddingHorizontal:20}):(p.button={width:"auto"},p.icon={padding:5}),l.jsx(i.TouchableHighlight,{underlayColor:"transparent",onPress:function(e){t.call("click",{})},style:d("button",p.button),children:l.jsxs(i.View,{style:d("buttonInner"),children:[s&&l.jsx(l.Fragment,{children:l.jsx(o.Ionicons,{size:30,style:d("buttonIcon",p.icon),name:s})}),a&&l.jsx(i.Text,{style:d("buttonLabel"),children:a})]})})}function b(e){var n=t.useState(!1),a=n[0],s=n[1],u=e.scope,d=r.Utils.nvl(u.getOptions(),[]),p=u.attr("placeholder","Selecione..."),f=u.getDisplayValue(),g=r.useTheme(),h=r.ViewUtils.getCrud("view"),x=function(){var e=!a;h.data.selectIsOpen=e,s(e)},y=function(e,t){return c({},S[e],u.getStyle(e),t)};return l.jsxs(i.View,{style:y("selectRoot"),children:[l.jsxs(i.TouchableOpacity,{onPress:x,style:y("selectInput"),children:[l.jsx(i.Text,{style:y("selectLabel"),children:r.Utils.nvl(f,p)}),l.jsx(o.Ionicons,{name:"arrow-down",size:20,color:"#888"})]}),l.jsxs(i.Modal,{animationType:"slide",transparent:!0,visible:a,onRequestClose:function(){return s(!1)},children:[l.jsx(i.StatusBar,{barStyle:"dark-content",backgroundColor:g.colors.primary}),l.jsxs(i.SafeAreaView,{style:y("modalSafe"),children:[l.jsxs(i.View,{style:y("modalHeader"),children:[l.jsx(i.TouchableOpacity,{onPress:function(){return s(!1)},style:y("modalCloseButton"),children:l.jsx(i.Text,{style:y("modalCloseText"),children:"X"})}),l.jsx(i.Text,{style:y("modalTitle"),children:p})]}),l.jsx(i.View,{style:y("modalContent"),children:l.jsx(Y.List,{data:d,name:u.getName("list"),click:function(e){u.changeValue(e.value),x()},children:l.jsx(Y.Value,{value:"#{@this.label}"})})})]})]})]})}var S=i.StyleSheet.create({selectRoot:{justifyContent:"flex-start",alignItems:"flex-start"},selectInput:{width:"100%",flexDirection:"row",borderWidth:1,borderColor:"#a9a9a9",borderRadius:20,paddingHorizontal:15,paddingVertical:10},selectLabel:{flex:1},modalSafe:{flex:1,backgroundColor:"#f5f5f5",paddingTop:i.StatusBar.currentHeight||0},modalHeader:{flexDirection:"row",alignItems:"center",padding:15,backgroundColor:"#6200ea"},modalCloseButton:{padding:10},modalCloseText:{fontSize:18,color:"white"},modalTitle:{fontSize:18,color:"white",fontWeight:"bold",marginLeft:10},modalContent:{flex:1,width:"100%",alignSelf:"flex-start",flexDirection:"row",flexWrap:"wrap",padding:20}});function w(e){var n=e.scope,a=r.Utils.nvl(n.getValue(),!1),o=t.useState(a),s=o[1];return l.jsx(i.Switch,{value:o[0],onValueChange:function(e){n.changeValue(e),s(e)}})}function C(e){return l.jsx(i.TouchableOpacity,{onPress:function(){i.Linking.openURL("https://reactnative.dev/")},children:l.jsx(i.Text,{style:T.link,children:"Clique aqui para acessar o React Native"})})}var T={link:{}};function k(e){return l.jsx(i.TouchableOpacity,{onPress:function(){i.Linking.openURL("https://reactnative.dev/")},children:l.jsx(i.Text,{style:I.link,children:"Clique aqui para acessar o React Native"})})}var I={link:{}};function U(e){var n=e.scope,a=r.Utils.nvl(n.getValue(),""),s=n.getLabel(),u=n.getPart("placeholder",null,s),d=n.original,p=t.useState(a),f=p[0],g=p[1];return l.jsxs(l.Fragment,{children:[n.getPart("left"),l.jsx(i.TextInput,{style:c({},n.getStyle("input",V.input),void 0),onChangeText:function(e){n.changeValue(e),g(e)},value:f,placeholder:u}),d.icon&&l.jsx(o.Ionicons,{name:d.icon,size:n.attr("iconSize",20),color:n.attr("iconColor","#888")}),n.getPart("right")]})}var V=i.StyleSheet.create({base:{flexDirection:"row",alignItems:"center",borderWidth:1,borderColor:"borderColor",borderRadius:20,paddingHorizontal:10,paddingVertical:5,padding:10,paddingLeft:5,paddingRight:10},icon:{marginRight:10},input:{marginHorizontal:0,marginVertical:0,height:40,flex:1}});function D(e){var n,a=e.scope,o=e.index,s=a.original,d=e.item,p=r.Utils.nvl(s.cols,1),f=Math.floor(100/p)+"%",g=null==(n={repeat:F,list:B})?void 0:n[s.type],h=""+a.key("row",o,""),x=t.useState(r.ScopeUtils.create(c({},s,{parent:a,name:h,crud:a.crud,index:o,type:"row",data:d})))[0],y=t.useState(0),m=y[0],j=y[1];x.update=function(){j(++m)};var v=function(){var e=x.getStyle("row",c({},g.row));return p>0&&(e.width=f),e};return s.click?l.jsx(i.TouchableHighlight,{style:v(),underlayColor:"transparent",onPress:function(e){e.stopPropagation(),function(e){x.call("click",{value:e,item:e,edit:!0})}(d)},children:l.jsx(u,{scope:x,crud:x.crud,children:e.children})},"k-"+o):l.jsx(i.View,{style:v(),children:l.jsx(u,{scope:x,crud:x.crud,children:e.children})},"k-"+o)}var B=i.StyleSheet.create({row:{padding:5,margin:3,width:"100%",backgroundColor:"#f5f5f5",gap:10,borderRadius:8}}),F=i.StyleSheet.create({row:{padding:0,width:"100%"}});function P(e){var t,n,a,s=e.scope,u=s.crud,d=s.original,p=r.Utils.nvl(d.cols,1),f=r.Utils.nvl(s.getItems(),[]),g=null==(t={repeat:R,list:L})?void 0:t[d.type],h=r.ComponentUtils.getDefine(e,"add"),x=d.hideAddWhenEmpty,y=function(){if(!r.Utils.isEmpty(f))return l.jsx(l.Fragment,{});var e=s.attr("empty","Sem registro");return e?"string"==typeof e?l.jsx(i.Text,{style:s.getStyle("empty",{flex:1,fontWeight:500,fontSize:20,padding:10,textAlign:"center",justifyContent:"center",alignItems:"center"}),children:e}):l.jsx(l.Fragment,{children:e}):l.jsx(l.Fragment,{})};return l.jsxs(l.Fragment,{children:[!1!==d.search&&l.jsx(Y.Text,{placeholder:"Pesquisar...",field:"query",crud:u,right:l.jsx(o.Ionicons,{name:"search",size:20,color:"#888"})}),l.jsxs(i.View,{style:(n={},a=s.getStyle("container",c({},n,g.container)),p>1&&(a=c({},a,{flexDirection:"row",flexWrap:"wrap"})),a),children:[l.jsx(y,{}),f.map((function(t,n){return l.jsx(D,{index:n,item:t,scope:s,children:e.children})})),(!r.Utils.isEmpty(f)||!0!==x)&&l.jsx(l.Fragment,{children:h})]})]})}var L=i.StyleSheet.create({container:{flex:1,width:"100%",flexDirection:"row",flexWrap:"wrap",alignItems:"stretch"},row:{padding:5,margin:3,width:"100%",backgroundColor:"#f5f5f5",gap:10,borderRadius:8},rowInner:{flexGrow:1,justifyContent:"center",alignItems:"center",borderRadius:8,padding:10,width:"100%"},text:{fontSize:18,fontWeight:"bold"}}),R=i.StyleSheet.create({container:{flex:1,width:"100%",flexDirection:"row",flexWrap:"wrap",gap:10,alignItems:"stretch"},row:{padding:0,width:"100%"},rowInner:{flexGrow:1,justifyContent:"center",alignItems:"center",padding:0,width:"100%"},text:{fontSize:18,fontWeight:"bold"}});function z(e){var n=e.scope,a=r.Utils.nvl(n.getOptions(),[]),o=n.getInputValue(),s=t.useState(0),u=s[0],d=s[1],p=function(e){return(null==e?void 0:e.value)===o},f=function(t){var a=t.item,o=t.index,s=p(a),u=c({},W.text);return s&&(u.color="#ffffff"),r.Utils.isEmpty(e.children)?l.jsx(i.Text,{style:u,children:a.label}):l.jsx(D,{scope:n,item:a.object,index:o,children:e.children})},g=function(e){var t=c({},W.item,n.getStyle("item")),r=Math.floor(100/a.length)+"%";if(p(e)){var i=n.getPart("selectedColor",void 0,"primary");(t=c({},t,n.getStyle("selected",{backgroundColor:i,color:"#ffffff"}))).color||(t.color="#ffffff")}return t.width=r,t};return l.jsx(l.Fragment,{children:a.map((function(e,t){return l.jsx(i.TouchableHighlight,{style:g(e),onPress:function(t){!function(e){n.changeValue(e.object),d(++u)}(e)},children:l.jsx(f,{item:e,index:t})},"k-"+t)}))})}var W=i.StyleSheet.create({container:{flex:1,width:"100%",gap:10,justifyContent:"center",flexDirection:"row"},item:{padding:15,marginVertical:8,backgroundColor:"#f5f5f5",borderRadius:8,justifyContent:"center",width:"auto",flexDirection:"row"},text:{fontSize:16,fontWeight:"500"}});function q(e){var n=e.scope,a=n.original,s=t.useState(0),u=s[0],d=s[1],p=n.getValue(0),f=a.color;f||(f="primary");var g={padding:10,alignItems:"center",height:44,width:44,textAlign:"center",verticalAling:"middle",borderRadius:24,backgroundColor:f,color:"#ffffff",justifyContent:"center"},h={buttonLabel:{color:"#ffffff",fontWeight:"500",fontSize:16},value:{flex:1,flexDirection:"row",textAlign:"center"},buttonInner:{flexDirection:"row",alignItems:"center",justifyContent:"center"},buttonIcon:{color:"#fff",fontSize:18},button:g,addButton:c({},g),delButton:c({},g)},x=function(e){n.changeValue(p+e),d(++u)},y=function(e,t){var r=c({},h[e],t);return n.getStyle(e,r)};return l.jsxs(l.Fragment,{children:[l.jsx(i.TouchableHighlight,{underlayColor:"transparent",onPress:function(){x(-1)},style:y("delButton"),children:l.jsx(o.Ionicons,{size:30,style:y("buttonIcon"),name:"remove"})}),l.jsx(i.Text,{style:y("value"),children:r.Utils.nvl(p,0)}),l.jsx(i.TouchableHighlight,{underlayColor:"transparent",onPress:function(){x(1)},style:y("addButton"),children:l.jsx(o.Ionicons,{size:30,style:y("buttonIcon"),name:"add"})})]})}function E(e){var n=t.useState(!1),a=n[0],o=n[1],s=t.useState(0),d=s[0],p=s[1],f=r.ViewUtils.getCrud("view"),g=e.scope,h=g.getLabel(),x=r.useTheme(),y=function(e,t){var n=c({},O[e],t);return c({},g.getStyle(e,n))},m=function(){g.close({scope:g,crud:g.currentDialog,event:{}})},j=function(e){o(a=e)};g.update=function(){p(++d)},g.show=function(e){var t=e.crud,n=g.getName("modal"),i=!0===e.edit,l={},a=null;t.is("row")?(l.parent=t.parent.parent,l.search=t.parent,a=t.data):t.is("search")&&(l.parent=t.parent,l.search=t);var o=r.Utils.nvl(e.item,a,{}),s=r.CrudUtils.create("dialog",c({parent:t,root:t,name:n,dialog:f.dialog,data:o,edit:i,scope:g},l));f.dialog=s,g.currentDialog=s,j(!0)},g.hide=function(e){var t;f.dialog=r.Utils.nvl(g.currentDialog.dialog,null),g.currentDialog=null,j(!1),null!=(t=f.dialog)&&t.scope&&f.dialog.scope.update()},t.useEffect((function(){i.StatusBar.setBarStyle("light-content"),null==i.StatusBar.setBackgroundColor||i.StatusBar.setBackgroundColor(x.colors.primary)}),[a]);var v=g.currentDialog;if(!v)return l.jsx(l.Fragment,{});if(v.uuid!==f.dialog.uuid)return l.jsx(l.Fragment,{});var b=r.ComponentUtils.getDefine(e,"header","right");return l.jsx(i.Modal,{animationType:"slide",transparent:!0,visible:a,onRequestClose:m,children:l.jsxs(i.SafeAreaView,{style:y("modalSafe"),children:[l.jsxs(i.View,{style:y("modalHeader"),children:[l.jsx(i.TouchableOpacity,{onPress:m,style:y("modalCloseButton"),children:l.jsx(i.Text,{style:y("modalCloseText"),children:"X"})}),l.jsx(i.Text,{style:y("modalTitle"),children:h}),!r.Utils.isEmpty(b)&&l.jsx(u,{scope:g,crud:g.currentDialog,transient:!0,children:b})]}),l.jsx(i.ScrollView,{contentContainerStyle:{flexGrow:1},style:y("modalContent"),children:l.jsx(i.View,{style:{flex:1},children:l.jsx(u,{scope:g,crud:g.currentDialog,children:e.children})})})]})})}var O=i.StyleSheet.create({modalSafe:{flex:1,backgroundColor:"primary",width:"100%"},modalHeader:{flexDirection:"row",alignItems:"center",padding:15,backgroundColor:"primary"},modalCloseButton:{padding:10},modalCloseText:{fontSize:18,color:"white"},modalTitle:{fontSize:18,color:"white",fontWeight:"bold",marginLeft:10},modalContent:{flex:1,backgroundColor:"#f5f5f5",padding:20}});function H(e){var n=e.scope,a=e.children,o=r.useTheme(),s=n.getPart("header",null,[]);return t.useEffect((function(){i.StatusBar.setBarStyle("light-content"),null==i.StatusBar.setBackgroundColor||i.StatusBar.setBackgroundColor(o.colors.primary)}),[]),l.jsxs(l.Fragment,{children:[s,l.jsx(i.View,{style:n.getStyle("container",N.container),children:l.jsx(i.ScrollView,{keyboardShouldPersistTaps:"handled",contentContainerStyle:n.getStyle("contentContainer",{}),style:n.getStyle("scroll",N.scroll),children:l.jsx(u,{scope:n,children:a})})})]})}var N=i.StyleSheet.create({scroll:{padding:10},container:{backgroundColor:"primary"},view:{backgroundColor:"primary"}}),A=t.createContext({});function M(e){var n,a,s=t.useContext(A),d=r.Utils.nvl(e.theme,null==s?void 0:s.theme),g=r.Utils.nvl(e.crud,null==s?void 0:s.crud),h=t.useState(r.ScopeUtils.create(c({crud:g},e,{theme:d})))[0],m=t.useState(0),S=m[0],T=m[1],I=t.useState(null),V=I[0],D=I[1];g=h.crud;var B=h.getOptions(),F=h.original,L=t.useRef(null);h.update=function(){T(++S)},h.updateElement=function(){T(++S)};var R=function(){var e=F.custom;return e?l.jsx(M,"string"==typeof e?{element:{value:e,type:"dummy"},crud:g}:c({type:e.type,tag:e.type},e.props,{crud:g})):l.jsx(l.Fragment,{})};if(h.is("type","dummy"))return l.jsx(l.Fragment,{children:h.getDisplayValue()});var W=function(e){var t=e.target.value;h.isType("integer","int","number")?t=parseInt(t):h.isType("decimal")&&(t=parseFloat(t)),h.isType("select","complete")&&(t=h.getSelectedItem(t)),h.changeValue(t),h.update()},O=function(e){h.call("click")},N={scope:h,crud:g,onChange:W};h.isType("password")&&(N.type="password");var G=function(){return!(h.isInput()||r.Utils.isEmpty(e.children)&&r.Utils.isEmpty(e.elements))},Q=h.is("type","text","number","phone","postalCode","money","password","email"),J=function(e){var t,n=r.Utils.nvl(F.type,"none"),i=r.Utils.nvl(e,"root"),l=c({},X[i]),a=G();return e||a||(l=c({},l)),h.isInput()&&(l=c({},l,K.input[i])),l=c({},l,null==K||null==(t=K[n])?void 0:t[i]),a&&e&&(l=c({},l,_[e])),c({},l,h.getStyle(e,l))},Y=J("element"),Z={required:h.isRequired(),size:"small",scope:h,crud:g,style:Y,placeholder:h.attr("placeholder","Digite aqui")};h.error=function(e){V=e,D(e)},null!=(n=F.list)&&n.url||null!=(a=F.load)&&a.url||h.start(),t.useEffect((function(){h.start()}));var $=function(){return"string"==typeof F.icon?l.jsx(o.Ionicons,{name:F.icon,style:h.getStyle("icon")}):l.jsx(l.Fragment,{children:F.icon})};if(h.open=function(e){i.Linking.openURL(e.url)},t.useLayoutEffect((function(){if(null!=L&&L.current&&h.is("type","card","list","tabs","stepper")){var e=null==L?void 0:L.current;if(null!=e&&e.classList){var t=r.HtmlUtils.getBGColor(e);e.classList.add("rgb(255, 255, 255)"===t?"ui-dark":"ui-light")}}})),!h.isRendered()||h.is("type","define"))return l.jsx(l.Fragment,{});var ee=i.View,te={};return!h.isType("input","grid","list","repeat")&&F.click&&(ee=i.TouchableHighlight,te.underlayColor="transparent",te.onPress=O),l.jsx(A.Provider,{value:{crud:g,theme:d},children:l.jsx(ee,c({ref:L,style:J()},te,{children:l.jsxs(l.Fragment,{children:[void 0!==F.label&&!1!==F.label&&!h.isType("button","dialog","modal")&&l.jsx(i.Text,{style:J("label"),children:h.getLabel()}),!G()&&l.jsxs(l.Fragment,{children:[l.jsxs(i.View,{style:J("inner"),children:[h.is("type","button")&&l.jsxs(v,c({},Z,{onClick:O,variant:h.attr("variant","outlined"),children:[F.icon&&l.jsx($,{}),F.label&&l.jsx(i.Text,{style:h.getPart("label","button"),children:h.getLabel()})]})),h.is("type","icon")&&l.jsx(j,c({},Z,{onClick:O,variant:h.attr("variant","outlined"),children:h.getDisplayValue()})),h.is("type","link")&&l.jsxs(y,c({},Z,{onClick:O,variant:h.attr("variant","outlined"),children:[F.icon&&l.jsx($,{}),F.label&&l.jsx(i.Text,{style:h.getPart("label","link"),children:h.getLabel()})]})),Q&&l.jsx(U,c({},N,Z,{InputProps:c({},F.inputProps)})),h.is("type","complete","autocomplete")&&l.jsx(x,{scope:h,defaultsInput:N,defaultsUI:Z}),h.is("type","quantity")&&l.jsx(q,{scope:h,defaultsInput:N,defaultsUI:Z}),h.is("type","checkbox","boolean","switch")&&l.jsx(w,c({checked:!0===h.getValue()},N,{onChange:function(){var e=h.getValue();W({target:{value:!(!0===e)}})}})),h.is("type","select")&&l.jsx(b,c({},N,Z,{value:h.getSelectedValue()})),h.is("type","toggle")&&l.jsx(z,c({},N,Z,{value:h.getSelectedValue()})),h.is("type","radio")&&l.jsx(k,c({},N,Z,{row:!0,children:B.map((function(e,t){return l.jsx(C,{control:l.jsx(k,c({},Z)),label:e.label,value:e.value},"i"+t)}))})),h.is("type","custom")&&l.jsx(R,{}),h.is("type","column")&&l.jsxs(l.Fragment,{children:[h.is("format","img")&&l.jsx(i.Image,{source:h.getDisplayValue()}),h.is("format","icon")&&l.jsx(j,{scope:h,crud:g}),!h.is("format","icon","img")&&l.jsx(i.Text,{children:h.getDisplayValue()})]}),h.is("type","output","value")&&l.jsx(i.Text,{style:J("value"),children:h.getDisplayValue()})]}),V&&l.jsx(i.View,{style:J("error"),children:V})]}),h.isType("list","repeat")&&l.jsx(P,c({},e,{scope:h,crud:g})),h.isType("dialog")&&l.jsx(E,c({},e,{scope:h,crud:g})),h.isType("chart")&&l.jsx(f,c({},e,{scope:h,crud:g})),h.isType("tabs")&&l.jsx(p,c({},e,{scope:h,crud:g})),h.isType("view")&&l.jsx(H,c({},e,{scope:h,crud:g})),!h.isType("tabs","view","grid","list","define","repeat","modal","dialog","chart")&&l.jsx(u,c({},e,{scope:h,crud:g,style:J("inner")}))]})}))})}var G={backgroundColor:"white",padding:16,borderRadius:10,width:"100%",shadowColor:"#888",shadowOffset:{width:0,height:1},shadowOpacity:.25,shadowRadius:3.84,elevation:3},K={view:{inner:{width:"100%",alignItems:"normal",flex:1},container:{width:"100%",backgroundColor:"#f5f5f5",flex:1,gap:10},child:{width:"100%",flex:1,gap:10,padding:10},root:{width:"100%",flex:1,alignItems:"normal",padding:0}}};K.card=i.StyleSheet.create({root:c({},G),inner:{flex:1,width:"100%",paddingBottom:10,paddingTop:5,alignSelf:"flex-start",flexDirection:"row",flexWrap:"wrap",gap:10}}),K.input=i.StyleSheet.create({label:{paddingLeft:8},inner:{flex:1,width:"100%",paddingBottom:0,paddingTop:0,alignItems:"center",borderWidth:1,borderColor:"borderColor",borderRadius:20,paddingHorizontal:15,alignSelf:"flex-start",flexDirection:"row",flexWrap:"wrap"}}),K.quantity={inner:c({},G,{backgroundColor:"primarySoft",fontWeight:600,fontSize:16,borderRadius:25,borderWidth:0,padding:5,paddingHorizontal:5,paddingVertical:5,flexWrap:"nowrap",flex:1,flexDirection:"row",justifyContent:"center",alignItems:"center"})},K.toggle=i.StyleSheet.create({inner:c({},G,{flex:1,width:"100%",gap:10,justifyContent:"center",flexDirection:"row",paddingHorizontal:10,paddingVertical:0,alignSelf:"flex-start",flexWrap:"nowrap"})});var X=i.StyleSheet.create({root:{gap:5,flexDirection:"column",flexWrap:"wrap",width:"100%",alignItems:"flex-start"},label:{width:"100%",fontWeight:400,fontSize:12,color:"labelColor"},inner:{width:"100%"}}),_=i.StyleSheet.create({root:{gap:10},label:{width:"100%",fontWeight:500,fontSize:24}});function Q(e){if(!1===e.rendered)return l.jsx(l.Fragment,{});var t=r.ComponentUtils.getDefine(e,e.name,e.position);return r.Utils.isEmpty(t)&&(t=e.default),r.Utils.isEmpty(t)?l.jsx(l.Fragment,{children:t}):l.jsx((function(t){var n=e.tag;return r.Utils.isEmpty(n)?l.jsx(l.Fragment,{children:t.children}):l.jsx(n,c({},t,{children:t.children}))}),c({},e.tagProps,{children:l.jsx(u,c({transient:!0},e,{scope:e.scope,crud:e.crud,part:e.name,children:t}))}))}var J=["type"],Y={List:function(e){return l.jsx(M,c({},e,{type:"list"}))},Row:function(e){return l.jsx(M,c({},e,{type:"row"}))},Value:function(e){return l.jsx(M,c({},e,{type:"value"}))},Label:function(e){return l.jsx(M,c({},e,{type:"label"}))},Repeat:function(e){return l.jsx(M,c({},e,{type:"repeat",props:{search:!1}}))},Define:function(e){return l.jsx(M,c({},e,{type:"define"}))},Include:function(e){return l.jsx(Q,c({},e))},Column:function(e){var t=function(e,t){if(null==e)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,J);return l.jsx(M,c({},t,{type:"column"}))},Input:function(e){return l.jsx(M,c({},e))},Text:function(e){return l.jsx(M,c({},e,{type:"text"}))},Email:function(e){return l.jsx(M,c({},e,{type:"email"}))},Button:function(e){return l.jsx(M,c({},e,{type:"button"}))},Link:function(e){return l.jsx(M,c({},e,{type:"link"}))},Icon:function(e){return l.jsx(M,c({},e,{type:"icon"}))},Output:function(e){return l.jsx(M,c({},e,{type:"output"}))},Form:function(e){return l.jsx(M,c({},e,{type:"form"}))},Crud:function(e){return l.jsx(M,c({},e,{type:"crud"}))},View:function(e){return l.jsx(M,c({},e,{type:"view",transient:!0}))},Bottom:function(e){return l.jsx(M,c({},e,{type:"bottom"}))},Dialog:function(e){return l.jsx(M,c({},e,{type:"dialog"}))},Content:function(e){return l.jsx(M,c({},e,{type:"content"}))},Top:function(e){return l.jsx(M,c({},e,{type:"top"}))},Card:function(e){return l.jsx(M,c({},e,{type:"card"}))},Tab:function(e){return l.jsx(M,c({},e,{type:"tab"}))},Tabs:function(e){return l.jsx(M,c({},e,{type:"tabs"}))},Step:function(e){return l.jsx(M,c({},e,{type:"tab",layout:"step"}))},Stepper:function(e){return l.jsx(M,c({},e,{type:"tabs",layout:"stepper"}))},Money:function(e){return l.jsx(M,c({},e,{type:"money"}))},Chart:function(e){return l.jsx(M,c({},e,{type:"chart"}))},Password:function(e){return l.jsx(M,c({},e,{type:"password"}))},Complete:function(e){return l.jsx(M,c({},e,{type:"complete"}))},Checkbox:function(e){return l.jsx(M,c({},e,{type:"switch"}))},Switch:function(e){return l.jsx(M,c({},e,{type:"switch"}))},Radio:function(e){return l.jsx(M,c({},e,{type:"radio"}))},Select:function(e){return l.jsx(M,c({},e,{type:"select"}))},Toggle:function(e){return l.jsx(M,c({},e,{type:"toggle"}))},Entity:function(e){return l.jsx(M,c({},e,{type:"entity"}))},Element:function(e){return l.jsx(M,c({},e,{type:"element"}))},Quantity:function(e){return l.jsx(M,c({},e,{type:"quantity"}))},SafeView:function(e){var n,a=r.useTheme();return t.useEffect((function(){i.StatusBar.setBarStyle("light-content"),null==i.StatusBar.setBackgroundColor||i.StatusBar.setBackgroundColor(a.colors.primary)}),[]),l.jsxs(s.SafeAreaProvider,{children:[l.jsx(i.StatusBar,{barStyle:"light-content"}),l.jsx(s.SafeAreaView,{style:c({backgroundColor:null==(n=a.colors)?void 0:n.primary},e.viewStyle,{flex:1}),children:l.jsx(i.KeyboardAvoidingView,{behavior:"ios"===i.Platform.OS?"padding":"height",style:{flex:1,justifyContent:"center"},children:l.jsx(i.TouchableWithoutFeedback,{onPress:function(){"web"!==i.Platform.OS&&i.Keyboard.dismiss()},accessible:!1,children:l.jsx(l.Fragment,{children:e.children})})})})]})}};exports.UI=Y;
1
+ "use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react"),n=e(t),r=require("react-crud-utils"),i=require("react-native"),l=require("react/jsx-runtime"),a=e(require("@expo/vector-icons/Ionicons")),o=require("@expo/vector-icons"),s=require("react-native-safe-area-context");function c(){return(c=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(null,arguments)}function u(e){var a=t.useState(r.Utils.nvl(e.scope,r.ScopeUtils.create(e)))[0],o=r.Utils.nvl(e.crud,a.crud),s=r.Utils.nvl(e.validateScope,"global"),p=r.Utils.nvl(e.part,"child");if(a.isInput())return l.jsx(l.Fragment,{});var f,g,h,x,y,m=function(e){var t=e.child;if(!t)return l.jsx(l.Fragment,{});if("string"==typeof t)return l.jsx(l.Fragment,{children:t});var n=t.type,i=c({},t.props);return delete i.children,"string"==typeof n?r.Utils.isEmpty(t.props.children)?l.jsx(n,c({},i)):l.jsx(n,c({},i,{children:l.jsx(u,c({transient:!0,validateScope:s},t.props,{scope:a,crud:o}))})):"function"==typeof n?l.jsx(n,c({validateScope:s},t.props,{parent:a,crud:o})):r.Utils.isEmpty(t.props.children)?l.jsx(l.Fragment,{}):l.jsx(u,c({validateScope:s},t.props,{scope:a,crud:o,transient:!0}))},j=function(){return l.jsx(l.Fragment,e.elements?{children:Object.entries(e.elements).map((function(e,t){return l.jsx(M,c({crud:o},e[1]))}))}:{children:n.Children.map(e.children,(function(e){return l.jsx(m,{child:e})}))})};return e.transient?l.jsx(j,{}):r.Utils.isEmpty(e.children)&&r.Utils.isEmpty(e.elements)?l.jsx(l.Fragment,{}):l.jsx(l.Fragment,{children:l.jsx(i.View,{style:(f=p,h=r.Utils.nvl(f,"root"),x=d[h],y={},r.Utils.isEmpty(e.style)||(null!=(g=e.style)&&g.push?r.Utils.each(e.style,(function(e){e&&(y=c({},y,e))})):y=c({},e.style)),c({},x,y,a.getStyle(f))),children:l.jsx(j,{})})})}var d=i.StyleSheet.create({child:{width:"100%"},inner:{width:"100%"}});function p(e){var i=e.scope,o=t.useState(0),s=o[0],d=o[1],p=i.original,f=i.getItems(),g=0,h=[],x=t.useState(null),y=x[0],m=x[1],j=function(e,t){void 0===t&&(t=!0),e&&i.execute({event:{validate:t,validateScope:p.validateScope,action:function(){i.changeValue(e.data),y=e,d(s=e.index),m(e)}}})},v=function(e){var t,n="ui-tabs-item ui-click";return(null==(t=y)?void 0:t.index)===e.index&&(n+=" ui-tab-selected"),n},b=function(e,t){var n=c({},e.props);t||(t=i.crud.data);var l=r.CrudUtils.create("tabs",{data:t,changed:t,parent:i.crud}),a=r.Utils.resolve(n,l);!1!==a.rendered&&h.push(c({},a,{child:e,element:a,original:n,index:g++,data:t}))};n.Children.map(e.children,(function(e,t){if(r.Utils.isEmpty(f))b(e,{});else for(var n in f)b(e,f[n])})),y||j(h[s],!1);var S=function(e){j(h[s+e])},w="stepper"===p.layout;return l.jsx("div",{className:i.getStyleClass("inner"),style:i.getStyle("inner"),children:l.jsxs("div",{className:"ui-tabs-content",children:[l.jsx("div",{className:"ui-tabs-items",children:h.map((function(e,t){return l.jsxs("div",{className:v(e),onClick:function(){j(e)},children:[w&&l.jsx("div",{className:"ui-tab-item-divisor"}),l.jsxs("div",{className:"ui-tab-item-inner",children:[w&&l.jsx("div",{className:"ui-step-line"}),l.jsx("div",{className:"ui-tab-item-label",children:w?e.index+1:e.label})]})]},r.Utils.key(p.id,"tab",t))}))}),y&&l.jsxs(l.Fragment,{children:[w&&l.jsx("div",{className:"ui-tabs-label",children:y.label}),l.jsx("div",{className:"ui-tabs-area",children:l.jsx(u,c({},e,{scope:i,children:y.child}))}),"stepper"===p.layout&&l.jsxs("div",{className:"ui-tabs-actions",children:[l.jsx(Y.Output,{space:6,layout:"left",children:l.jsx(Y.Include,c({},e,{transient:!0,name:"left",default:l.jsx(Y.Button,{rendered:s>0,icon:l.jsx(a,{}),click:function(){S(-1)}})}))}),l.jsx(Y.Output,{space:6,layout:"right",children:l.jsx(Y.Include,c({},e,{transient:!0,name:"right",default:l.jsx(Y.Button,{rendered:s<h.length-1,icon:l.jsx(a,{}),click:function(){S(1)}})}))})]})]})]})})}function f(e){var t=e.scope;return t.getItems(),r.Utils.asList(t.original.columns),l.jsx("div",{className:"ui-chart-data"})}function g(e){return l.jsx(i.TouchableOpacity,{onPress:function(){i.Linking.openURL("https://reactnative.dev/")},children:l.jsx(i.Text,{style:h.link,children:"Clique aqui para acessar o React Native"})})}var h={link:{}};function x(e){return l.jsx(l.Fragment,{children:l.jsx(g,c({},e.defaultsInput,e.defaultsUI))})}function y(e){return l.jsx(i.TouchableOpacity,{onPress:function(){i.Linking.openURL("https://reactnative.dev/")},children:l.jsx(i.Text,{style:m.link,children:"Clique aqui para acessar o React Native"})})}var m={link:{}};function j(e){var t=e.scope,n=t.getValue();return l.jsx(o.Ionicons,{name:n,style:t.getStyle("icon")})}function v(e){var t=e.scope,n=t.original,r=n.color,a=n.label,s=n.icon;r||(r="primaryLight");var u={buttonLabel:{color:"#ffffff",fontWeight:"500",fontSize:16,paddingRight:10,paddingLeft:10},buttonInner:{flexDirection:"row",alignItems:"center",justifyContent:"center",height:44,minWidth:44},buttonIcon:{color:"#fff",fontSize:18},button:{alignItems:"center",margin:"auto",width:"100%",textAlign:"center",verticalAling:"middle",borderRadius:24,backgroundColor:r,color:"#ffffff",justifyContent:"center",flex:1}},d=function(e,n){var r=c({},u[e],n);return t.getStyle(e,r)},p={};return a?s&&(p.button={padding:0,paddingHorizontal:20}):(p.button={width:"auto"},p.icon={padding:5}),l.jsx(i.TouchableHighlight,{underlayColor:"transparent",onPress:function(e){t.call("click",{})},style:d("button",p.button),children:l.jsxs(i.View,{style:d("buttonInner"),children:[s&&l.jsx(l.Fragment,{children:l.jsx(o.Ionicons,{size:30,style:d("buttonIcon",p.icon),name:s})}),a&&l.jsx(i.Text,{style:d("buttonLabel"),children:a})]})})}function b(e){var n=t.useState(!1),a=n[0],s=n[1],u=e.scope,d=r.Utils.nvl(u.getOptions(),[]),p=u.attr("placeholder","Selecione..."),f=u.getDisplayValue(),g=r.useTheme(),h=r.ViewUtils.getCrud("view"),x=function(){var e=!a;h.data.selectIsOpen=e,s(e)},y=function(e,t){return c({},S[e],u.getStyle(e),t)};return l.jsxs(i.View,{style:y("selectRoot"),children:[l.jsxs(i.TouchableOpacity,{onPress:x,style:y("selectInput"),children:[l.jsx(i.Text,{style:y("selectLabel"),children:r.Utils.nvl(f,p)}),l.jsx(o.Ionicons,{name:"arrow-down",size:20,color:"#888"})]}),l.jsxs(i.Modal,{animationType:"slide",transparent:!0,visible:a,onRequestClose:function(){return s(!1)},children:[l.jsx(i.StatusBar,{barStyle:"dark-content",backgroundColor:g.colors.primary}),l.jsxs(i.SafeAreaView,{style:y("modalSafe"),children:[l.jsxs(i.View,{style:y("modalHeader"),children:[l.jsx(i.TouchableOpacity,{onPress:function(){return s(!1)},style:y("modalCloseButton"),children:l.jsx(i.Text,{style:y("modalCloseText"),children:"X"})}),l.jsx(i.Text,{style:y("modalTitle"),children:p})]}),l.jsx(i.View,{style:y("modalContent"),children:l.jsx(Y.List,{data:d,name:u.getName("list"),click:function(e){u.changeValue(e.value),x()},children:l.jsx(Y.Value,{value:"#{@this.label}"})})})]})]})]})}var S=i.StyleSheet.create({selectRoot:{justifyContent:"flex-start",alignItems:"flex-start"},selectInput:{width:"100%",flexDirection:"row",borderWidth:1,borderColor:"#a9a9a9",borderRadius:20,paddingHorizontal:15,paddingVertical:10},selectLabel:{flex:1},modalSafe:{flex:1,backgroundColor:"#f5f5f5",paddingTop:i.StatusBar.currentHeight||0},modalHeader:{flexDirection:"row",alignItems:"center",padding:15,backgroundColor:"#6200ea"},modalCloseButton:{padding:10},modalCloseText:{fontSize:18,color:"white"},modalTitle:{fontSize:18,color:"white",fontWeight:"bold",marginLeft:10},modalContent:{flex:1,width:"100%",alignSelf:"flex-start",flexDirection:"row",flexWrap:"wrap",padding:20}});function w(e){var n=e.scope,a=r.Utils.nvl(n.getValue(),!1),o=t.useState(a),s=o[1];return l.jsx(i.Switch,{value:o[0],onValueChange:function(e){n.changeValue(e),s(e)}})}function C(e){return l.jsx(i.TouchableOpacity,{onPress:function(){i.Linking.openURL("https://reactnative.dev/")},children:l.jsx(i.Text,{style:T.link,children:"Clique aqui para acessar o React Native"})})}var T={link:{}};function k(e){return l.jsx(i.TouchableOpacity,{onPress:function(){i.Linking.openURL("https://reactnative.dev/")},children:l.jsx(i.Text,{style:I.link,children:"Clique aqui para acessar o React Native"})})}var I={link:{}};function U(e){var n=e.scope,a=r.Utils.nvl(n.getValue(),""),s=n.getLabel(),u=n.getPart("placeholder",null,s),d=n.original,p=t.useState(a),f=p[0],g=p[1];return l.jsxs(l.Fragment,{children:[n.getPart("left"),l.jsx(i.TextInput,{style:c({},n.getStyle("input",V.input),void 0),onChangeText:function(e){n.changeValue(e),g(e)},value:f,placeholder:u}),d.icon&&l.jsx(o.Ionicons,{name:d.icon,size:n.attr("iconSize",20),color:n.attr("iconColor","#888")}),n.getPart("right")]})}var V=i.StyleSheet.create({base:{flexDirection:"row",alignItems:"center",borderWidth:1,borderColor:"borderColor",borderRadius:20,paddingHorizontal:10,paddingVertical:5,padding:10,paddingLeft:5,paddingRight:10},icon:{marginRight:10},input:{marginHorizontal:0,marginVertical:0,height:40,flex:1}});function D(e){var n,a=e.scope,o=e.index,s=a.original,d=e.item,p=r.Utils.nvl(s.cols,1),f=Math.floor(100/p)+"%",g=null==(n={repeat:F,list:B})?void 0:n[s.type],h=""+a.key("row",o,""),x=t.useState(r.ScopeUtils.create(c({},s,{parent:a,name:h,crud:a.crud,index:o,type:"row",data:d})))[0],y=function(){var e=x.getStyle("row",c({},g.row));return p>0&&(e.width=f),e};return l.jsx((function(){var n=t.useState(0),r=n[0],a=n[1];return x.update=function(){a(++r)},s.click?l.jsx(i.TouchableHighlight,{style:y(),underlayColor:"transparent",onPress:function(e){e.stopPropagation(),function(e){x.call("click",{value:e,item:e,edit:!0})}(d)},children:l.jsx(u,{scope:x,crud:x.crud,children:e.children})},"k-"+o):l.jsx(i.View,{style:y(),children:l.jsx(u,{scope:x,crud:x.crud,children:e.children})},"k-"+o)}),{})}var B=i.StyleSheet.create({row:{padding:5,margin:3,width:"100%",backgroundColor:"#f5f5f5",gap:10,borderRadius:8}}),F=i.StyleSheet.create({row:{padding:0,width:"100%"}});function P(e){var t,n,a,s=e.scope,u=s.crud,d=s.original,p=r.Utils.nvl(d.cols,1),f=r.Utils.nvl(s.getItems(),[]),g=null==(t={repeat:R,list:L})?void 0:t[d.type],h=r.ComponentUtils.getDefine(e,"add"),x=d.hideAddWhenEmpty,y=function(){if(!r.Utils.isEmpty(f))return l.jsx(l.Fragment,{});var e=s.attr("empty","Sem registro");return e?"string"==typeof e?l.jsx(i.Text,{style:s.getStyle("empty",{flex:1,fontWeight:500,fontSize:20,padding:10,textAlign:"center",justifyContent:"center",alignItems:"center"}),children:e}):l.jsx(l.Fragment,{children:e}):l.jsx(l.Fragment,{})};return l.jsxs(l.Fragment,{children:[!1!==d.search&&l.jsx(Y.Text,{placeholder:"Pesquisar...",field:"query",crud:u,right:l.jsx(o.Ionicons,{name:"search",size:20,color:"#888"})}),l.jsxs(i.View,{style:(n={},a=s.getStyle("container",c({},n,g.container)),p>1&&(a=c({},a,{flexDirection:"row",flexWrap:"wrap"})),a),children:[l.jsx(y,{}),f.map((function(t,n){return l.jsx(D,{index:n,item:t,scope:s,children:e.children})})),(!r.Utils.isEmpty(f)||!0!==x)&&l.jsx(l.Fragment,{children:h})]})]})}var L=i.StyleSheet.create({container:{flex:1,width:"100%",flexDirection:"row",flexWrap:"wrap",alignItems:"stretch"},row:{padding:5,margin:3,width:"100%",backgroundColor:"#f5f5f5",gap:10,borderRadius:8},rowInner:{flexGrow:1,justifyContent:"center",alignItems:"center",borderRadius:8,padding:10,width:"100%"},text:{fontSize:18,fontWeight:"bold"}}),R=i.StyleSheet.create({container:{flex:1,width:"100%",flexDirection:"row",flexWrap:"wrap",gap:10,alignItems:"stretch"},row:{padding:0,width:"100%"},rowInner:{flexGrow:1,justifyContent:"center",alignItems:"center",padding:0,width:"100%"},text:{fontSize:18,fontWeight:"bold"}});function z(e){var n=e.scope,a=r.Utils.nvl(n.getOptions(),[]),o=n.getInputValue(),s=t.useState(0),u=s[0],d=s[1],p=function(e){return(null==e?void 0:e.value)===o},f=function(t){var a=t.item,o=t.index,s=p(a),u=c({},W.text);return s&&(u.color="#ffffff"),r.Utils.isEmpty(e.children)?l.jsx(i.Text,{style:u,children:a.label}):l.jsx(D,{scope:n,item:a.object,index:o,children:e.children})},g=function(e){var t=c({},W.item,n.getStyle("item")),r=Math.floor(100/a.length)+"%";if(p(e)){var i=n.getPart("selectedColor",void 0,"primary");(t=c({},t,n.getStyle("selected",{backgroundColor:i,color:"#ffffff"}))).color||(t.color="#ffffff")}return t.width=r,t};return l.jsx(l.Fragment,{children:a.map((function(e,t){return l.jsx(i.TouchableHighlight,{style:g(e),onPress:function(t){!function(e){n.changeValue(e.object),d(++u)}(e)},children:l.jsx(f,{item:e,index:t})},"k-"+t)}))})}var W=i.StyleSheet.create({container:{flex:1,width:"100%",gap:10,justifyContent:"center",flexDirection:"row"},item:{padding:15,marginVertical:8,backgroundColor:"#f5f5f5",borderRadius:8,justifyContent:"center",width:"auto",flexDirection:"row"},text:{fontSize:16,fontWeight:"500"}});function q(e){var n=e.scope,a=n.original,s=t.useState(0),u=s[0],d=s[1],p=n.getValue(0),f=a.color;f||(f="primary");var g={padding:10,alignItems:"center",height:44,width:44,textAlign:"center",verticalAling:"middle",borderRadius:24,backgroundColor:f,color:"#ffffff",justifyContent:"center"},h={buttonLabel:{color:"#ffffff",fontWeight:"500",fontSize:16},value:{flex:1,flexDirection:"row",textAlign:"center"},buttonInner:{flexDirection:"row",alignItems:"center",justifyContent:"center"},buttonIcon:{color:"#fff",fontSize:18},button:g,addButton:c({},g),delButton:c({},g)},x=function(e){n.changeValue(p+e),d(++u)},y=function(e,t){var r=c({},h[e],t);return n.getStyle(e,r)};return l.jsxs(l.Fragment,{children:[l.jsx(i.TouchableHighlight,{underlayColor:"transparent",onPress:function(){x(-1)},style:y("delButton"),children:l.jsx(o.Ionicons,{size:30,style:y("buttonIcon"),name:"remove"})}),l.jsx(i.Text,{style:y("value"),children:r.Utils.nvl(p,0)}),l.jsx(i.TouchableHighlight,{underlayColor:"transparent",onPress:function(){x(1)},style:y("addButton"),children:l.jsx(o.Ionicons,{size:30,style:y("buttonIcon"),name:"add"})})]})}function E(e){var n=t.useState(!1),a=n[0],o=n[1],s=t.useState(0),d=s[0],p=s[1],f=r.ViewUtils.getCrud("view"),g=e.scope,h=g.getLabel(),x=r.useTheme(),y=function(e,t){var n=c({},O[e],t);return c({},g.getStyle(e,n))},m=function(){g.close({scope:g,crud:g.currentDialog,event:{}})},j=function(e){o(a=e)};g.update=function(){p(++d)},g.show=function(e){var t=e.crud,n=g.getName("modal"),i=!0===e.edit,l={},a=null;t.is("row")?(l.parent=t.parent.parent,l.search=t.parent,a=t.data):t.is("search")&&(l.parent=t.parent,l.search=t);var o=r.Utils.nvl(e.item,a,{}),s=r.CrudUtils.create("dialog",c({parent:t,root:t,name:n,dialog:f.dialog,data:o,edit:i,scope:g},l));f.dialog=s,g.currentDialog=s,j(!0)},g.hide=function(e){var t;f.dialog=r.Utils.nvl(g.currentDialog.dialog,null),g.currentDialog=null,j(!1),null!=(t=f.dialog)&&t.scope&&f.dialog.scope.update()},t.useEffect((function(){i.StatusBar.setBarStyle("light-content"),null==i.StatusBar.setBackgroundColor||i.StatusBar.setBackgroundColor(x.colors.primary)}),[a]);var v=g.currentDialog;if(!v)return l.jsx(l.Fragment,{});if(v.uuid!==f.dialog.uuid)return l.jsx(l.Fragment,{});var b=r.ComponentUtils.getDefine(e,"header","right");return l.jsx(i.Modal,{animationType:"slide",transparent:!0,visible:a,onRequestClose:m,children:l.jsxs(i.SafeAreaView,{style:y("modalSafe"),children:[l.jsxs(i.View,{style:y("modalHeader"),children:[l.jsx(i.TouchableOpacity,{onPress:m,style:y("modalCloseButton"),children:l.jsx(i.Text,{style:y("modalCloseText"),children:"X"})}),l.jsx(i.Text,{style:y("modalTitle"),children:h}),!r.Utils.isEmpty(b)&&l.jsx(u,{scope:g,crud:g.currentDialog,transient:!0,children:b})]}),l.jsx(i.ScrollView,{contentContainerStyle:{flexGrow:1},style:y("modalContent"),children:l.jsx(i.View,{style:{flex:1},children:l.jsx(u,{scope:g,crud:g.currentDialog,children:e.children})})})]})})}var O=i.StyleSheet.create({modalSafe:{flex:1,backgroundColor:"primary",width:"100%"},modalHeader:{flexDirection:"row",alignItems:"center",padding:15,backgroundColor:"primary"},modalCloseButton:{padding:10},modalCloseText:{fontSize:18,color:"white"},modalTitle:{fontSize:18,color:"white",fontWeight:"bold",marginLeft:10},modalContent:{flex:1,backgroundColor:"#f5f5f5",padding:20}});function H(e){var n=e.scope,a=e.children,o=r.useTheme(),s=n.getPart("header",null,[]);return t.useEffect((function(){i.StatusBar.setBarStyle("light-content"),null==i.StatusBar.setBackgroundColor||i.StatusBar.setBackgroundColor(o.colors.primary)}),[]),l.jsxs(l.Fragment,{children:[s,l.jsx(i.View,{style:n.getStyle("container",N.container),children:l.jsx(i.ScrollView,{keyboardShouldPersistTaps:"handled",contentContainerStyle:n.getStyle("contentContainer",{}),style:n.getStyle("scroll",N.scroll),children:l.jsx(u,{scope:n,children:a})})})]})}var N=i.StyleSheet.create({scroll:{padding:10},container:{backgroundColor:"primary"},view:{backgroundColor:"primary"}}),A=t.createContext({});function M(e){var n,a,s=t.useContext(A),d=r.Utils.nvl(e.theme,null==s?void 0:s.theme),g=r.Utils.nvl(e.crud,null==s?void 0:s.crud),h=t.useState(r.ScopeUtils.create(c({crud:g},e,{theme:d})))[0],m=t.useState(0),S=m[0],T=m[1],I=t.useState(null),V=I[0],D=I[1];g=h.crud;var B=h.getOptions(),F=h.original,L=t.useRef(null);h.update=function(){T(++S)},h.updateElement=function(){T(++S)};var R=function(){var e=F.custom;return e?l.jsx(M,"string"==typeof e?{element:{value:e,type:"dummy"},crud:g}:c({type:e.type,tag:e.type},e.props,{crud:g})):l.jsx(l.Fragment,{})};if(h.is("type","dummy"))return l.jsx(l.Fragment,{children:h.getDisplayValue()});var W=function(e){var t=e.target.value;h.isType("integer","int","number")?t=parseInt(t):h.isType("decimal")&&(t=parseFloat(t)),h.isType("select","complete")&&(t=h.getSelectedItem(t)),h.changeValue(t),h.update()},O=function(e){h.call("click")},N={scope:h,crud:g,onChange:W};h.isType("password")&&(N.type="password");var G=function(){return!(h.isInput()||r.Utils.isEmpty(e.children)&&r.Utils.isEmpty(e.elements))},Q=h.is("type","text","number","phone","postalCode","money","password","email"),J=function(e){var t,n=r.Utils.nvl(F.type,"none"),i=r.Utils.nvl(e,"root"),l=c({},X[i]),a=G();return e||a||(l=c({},l)),h.isInput()&&(l=c({},l,K.input[i])),l=c({},l,null==K||null==(t=K[n])?void 0:t[i]),a&&e&&(l=c({},l,_[e])),c({},l,h.getStyle(e,l))},Y=J("element"),Z={required:h.isRequired(),size:"small",scope:h,crud:g,style:Y,placeholder:h.attr("placeholder","Digite aqui")};h.error=function(e){V=e,D(e)},null!=(n=F.list)&&n.url||null!=(a=F.load)&&a.url||h.start(),t.useEffect((function(){h.start()}));var $=function(){return"string"==typeof F.icon?l.jsx(o.Ionicons,{name:F.icon,style:h.getStyle("icon")}):l.jsx(l.Fragment,{children:F.icon})};if(h.open=function(e){i.Linking.openURL(e.url)},t.useLayoutEffect((function(){if(null!=L&&L.current&&h.is("type","card","list","tabs","stepper")){var e=null==L?void 0:L.current;if(null!=e&&e.classList){var t=r.HtmlUtils.getBGColor(e);e.classList.add("rgb(255, 255, 255)"===t?"ui-dark":"ui-light")}}})),!h.isRendered()||h.is("type","define"))return l.jsx(l.Fragment,{});var ee=i.View,te={};return!h.isType("input","grid","list","repeat")&&F.click&&(ee=i.TouchableHighlight,te.underlayColor="transparent",te.onPress=O),l.jsx(A.Provider,{value:{crud:g,theme:d},children:l.jsx(ee,c({ref:L,style:J()},te,{children:l.jsxs(l.Fragment,{children:[void 0!==F.label&&!1!==F.label&&!h.isType("button","dialog","modal")&&l.jsx(i.Text,{style:J("label"),children:h.getLabel()}),!G()&&l.jsxs(l.Fragment,{children:[l.jsxs(i.View,{style:J("inner"),children:[h.is("type","button")&&l.jsxs(v,c({},Z,{onClick:O,variant:h.attr("variant","outlined"),children:[F.icon&&l.jsx($,{}),F.label&&l.jsx(i.Text,{style:h.getPart("label","button"),children:h.getLabel()})]})),h.is("type","icon")&&l.jsx(j,c({},Z,{onClick:O,variant:h.attr("variant","outlined"),children:h.getDisplayValue()})),h.is("type","link")&&l.jsxs(y,c({},Z,{onClick:O,variant:h.attr("variant","outlined"),children:[F.icon&&l.jsx($,{}),F.label&&l.jsx(i.Text,{style:h.getPart("label","link"),children:h.getLabel()})]})),Q&&l.jsx(U,c({},N,Z,{InputProps:c({},F.inputProps)})),h.is("type","complete","autocomplete")&&l.jsx(x,{scope:h,defaultsInput:N,defaultsUI:Z}),h.is("type","quantity")&&l.jsx(q,{scope:h,defaultsInput:N,defaultsUI:Z}),h.is("type","checkbox","boolean","switch")&&l.jsx(w,c({checked:!0===h.getValue()},N,{onChange:function(){var e=h.getValue();W({target:{value:!(!0===e)}})}})),h.is("type","select")&&l.jsx(b,c({},N,Z,{value:h.getSelectedValue()})),h.is("type","toggle")&&l.jsx(z,c({},N,Z,{value:h.getSelectedValue()})),h.is("type","radio")&&l.jsx(k,c({},N,Z,{row:!0,children:B.map((function(e,t){return l.jsx(C,{control:l.jsx(k,c({},Z)),label:e.label,value:e.value},"i"+t)}))})),h.is("type","custom")&&l.jsx(R,{}),h.is("type","column")&&l.jsxs(l.Fragment,{children:[h.is("format","img")&&l.jsx(i.Image,{source:h.getDisplayValue()}),h.is("format","icon")&&l.jsx(j,{scope:h,crud:g}),!h.is("format","icon","img")&&l.jsx(i.Text,{children:h.getDisplayValue()})]}),h.is("type","output","value")&&l.jsx(i.Text,{style:J("value"),children:h.getDisplayValue()})]}),V&&l.jsx(i.View,{style:J("error"),children:V})]}),h.isType("list","repeat")&&l.jsx(P,c({},e,{scope:h,crud:g})),h.isType("dialog")&&l.jsx(E,c({},e,{scope:h,crud:g})),h.isType("chart")&&l.jsx(f,c({},e,{scope:h,crud:g})),h.isType("tabs")&&l.jsx(p,c({},e,{scope:h,crud:g})),h.isType("view")&&l.jsx(H,c({},e,{scope:h,crud:g})),!h.isType("tabs","view","grid","list","define","repeat","modal","dialog","chart")&&l.jsx(u,c({},e,{scope:h,crud:g,style:J("inner")}))]})}))})}var G={backgroundColor:"white",padding:16,borderRadius:10,width:"100%",shadowColor:"#888",shadowOffset:{width:0,height:1},shadowOpacity:.25,shadowRadius:3.84,elevation:3},K={view:{inner:{width:"100%",alignItems:"normal",flex:1},container:{width:"100%",backgroundColor:"#f5f5f5",flex:1,gap:10},child:{width:"100%",flex:1,gap:10,padding:10},root:{width:"100%",flex:1,alignItems:"normal",padding:0}}};K.card=i.StyleSheet.create({root:c({},G),inner:{flex:1,width:"100%",paddingBottom:10,paddingTop:5,alignSelf:"flex-start",flexDirection:"row",flexWrap:"wrap",gap:10}}),K.input=i.StyleSheet.create({label:{paddingLeft:8},inner:{flex:1,width:"100%",paddingBottom:0,paddingTop:0,alignItems:"center",borderWidth:1,borderColor:"borderColor",borderRadius:20,paddingHorizontal:15,alignSelf:"flex-start",flexDirection:"row",flexWrap:"wrap"}}),K.quantity={inner:c({},G,{backgroundColor:"primarySoft",fontWeight:600,fontSize:16,borderRadius:25,borderWidth:0,padding:5,paddingHorizontal:5,paddingVertical:5,flexWrap:"nowrap",flex:1,flexDirection:"row",justifyContent:"center",alignItems:"center"})},K.toggle=i.StyleSheet.create({inner:c({},G,{flex:1,width:"100%",gap:10,justifyContent:"center",flexDirection:"row",paddingHorizontal:10,paddingVertical:0,alignSelf:"flex-start",flexWrap:"nowrap"})});var X=i.StyleSheet.create({root:{gap:5,flexDirection:"column",flexWrap:"wrap",width:"100%",alignItems:"flex-start"},label:{width:"100%",fontWeight:400,fontSize:12,color:"labelColor"},inner:{width:"100%"}}),_=i.StyleSheet.create({root:{gap:10},label:{width:"100%",fontWeight:500,fontSize:24}});function Q(e){if(!1===e.rendered)return l.jsx(l.Fragment,{});var t=r.ComponentUtils.getDefine(e,e.name,e.position);return r.Utils.isEmpty(t)&&(t=e.default),r.Utils.isEmpty(t)?l.jsx(l.Fragment,{children:t}):l.jsx((function(t){var n=e.tag;return r.Utils.isEmpty(n)?l.jsx(l.Fragment,{children:t.children}):l.jsx(n,c({},t,{children:t.children}))}),c({},e.tagProps,{children:l.jsx(u,c({transient:!0},e,{scope:e.scope,crud:e.crud,part:e.name,children:t}))}))}var J=["type"],Y={List:function(e){return l.jsx(M,c({},e,{type:"list"}))},Row:function(e){return l.jsx(M,c({},e,{type:"row"}))},Value:function(e){return l.jsx(M,c({},e,{type:"value"}))},Label:function(e){return l.jsx(M,c({},e,{type:"label"}))},Repeat:function(e){return l.jsx(M,c({},e,{type:"repeat",props:{search:!1}}))},Define:function(e){return l.jsx(M,c({},e,{type:"define"}))},Include:function(e){return l.jsx(Q,c({},e))},Column:function(e){var t=function(e,t){if(null==e)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,J);return l.jsx(M,c({},t,{type:"column"}))},Input:function(e){return l.jsx(M,c({},e))},Text:function(e){return l.jsx(M,c({},e,{type:"text"}))},Email:function(e){return l.jsx(M,c({},e,{type:"email"}))},Button:function(e){return l.jsx(M,c({},e,{type:"button"}))},Link:function(e){return l.jsx(M,c({},e,{type:"link"}))},Icon:function(e){return l.jsx(M,c({},e,{type:"icon"}))},Output:function(e){return l.jsx(M,c({},e,{type:"output"}))},Form:function(e){return l.jsx(M,c({},e,{type:"form"}))},Crud:function(e){return l.jsx(M,c({},e,{type:"crud"}))},View:function(e){return l.jsx(M,c({},e,{type:"view",transient:!0}))},Bottom:function(e){return l.jsx(M,c({},e,{type:"bottom"}))},Dialog:function(e){return l.jsx(M,c({},e,{type:"dialog"}))},Content:function(e){return l.jsx(M,c({},e,{type:"content"}))},Top:function(e){return l.jsx(M,c({},e,{type:"top"}))},Card:function(e){return l.jsx(M,c({},e,{type:"card"}))},Tab:function(e){return l.jsx(M,c({},e,{type:"tab"}))},Tabs:function(e){return l.jsx(M,c({},e,{type:"tabs"}))},Step:function(e){return l.jsx(M,c({},e,{type:"tab",layout:"step"}))},Stepper:function(e){return l.jsx(M,c({},e,{type:"tabs",layout:"stepper"}))},Money:function(e){return l.jsx(M,c({},e,{type:"money"}))},Chart:function(e){return l.jsx(M,c({},e,{type:"chart"}))},Password:function(e){return l.jsx(M,c({},e,{type:"password"}))},Complete:function(e){return l.jsx(M,c({},e,{type:"complete"}))},Checkbox:function(e){return l.jsx(M,c({},e,{type:"switch"}))},Switch:function(e){return l.jsx(M,c({},e,{type:"switch"}))},Radio:function(e){return l.jsx(M,c({},e,{type:"radio"}))},Select:function(e){return l.jsx(M,c({},e,{type:"select"}))},Toggle:function(e){return l.jsx(M,c({},e,{type:"toggle"}))},Entity:function(e){return l.jsx(M,c({},e,{type:"entity"}))},Element:function(e){return l.jsx(M,c({},e,{type:"element"}))},Quantity:function(e){return l.jsx(M,c({},e,{type:"quantity"}))},SafeView:function(e){var n,a=r.useTheme();return t.useEffect((function(){i.StatusBar.setBarStyle("light-content"),null==i.StatusBar.setBackgroundColor||i.StatusBar.setBackgroundColor(a.colors.primary)}),[]),l.jsxs(s.SafeAreaProvider,{children:[l.jsx(i.StatusBar,{barStyle:"light-content"}),l.jsx(s.SafeAreaView,{style:c({backgroundColor:null==(n=a.colors)?void 0:n.primary},e.viewStyle,{flex:1}),children:l.jsx(i.KeyboardAvoidingView,{behavior:"ios"===i.Platform.OS?"padding":"height",style:{flex:1,justifyContent:"center"},children:l.jsx(i.TouchableWithoutFeedback,{onPress:function(){"web"!==i.Platform.OS&&i.Keyboard.dismiss()},accessible:!1,children:l.jsx(l.Fragment,{children:e.children})})})})]})}};exports.UI=Y;
2
2
  //# sourceMappingURL=react-crud-mobile.cjs.production.min.js.map