react-crud-mobile 1.0.607 → 1.0.608
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/dist/react-crud-mobile.cjs.development.js +49 -46
- package/dist/react-crud-mobile.cjs.development.js.map +1 -1
- package/dist/react-crud-mobile.cjs.production.min.js +1 -1
- package/dist/react-crud-mobile.cjs.production.min.js.map +1 -1
- package/dist/react-crud-mobile.esm.js +49 -46
- package/dist/react-crud-mobile.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/elements/core/UIList.tsx +24 -32
- package/src/elements/core/UIListRow.tsx +13 -1
|
@@ -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,x=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}))},h=function(){return l.jsx(l.Fragment,e.elements?{children:Object.entries(e.elements).map((function(e,t){return l.jsx(N,c({crud:o},e[1]))}))}:{children:n.Children.map(e.children,(function(e){return l.jsx(x,{child:e})}))})};return e.transient?l.jsx(h,{}):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,g=r.Utils.nvl(f,"root"),c({},d[g],e.style,a.getStyle(f))),children:l.jsx(h,{})})})}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,x=[],h=t.useState(null),y=h[0],m=h[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&&x.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(x[s],!1);var S=function(e){j(x[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:x.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(Q.Output,{space:6,layout:"left",children:l.jsx(Q.Include,c({},e,{transient:!0,name:"left",default:l.jsx(Q.Button,{rendered:s>0,icon:l.jsx(a,{}),click:function(){S(-1)}})}))}),l.jsx(Q.Output,{space:6,layout:"right",children:l.jsx(Q.Include,c({},e,{transient:!0,name:"right",default:l.jsx(Q.Button,{rendered:s<x.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:x.link,children:"Clique aqui para acessar o React Native"})})}var x={link:{}};function h(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(),x=r.ViewUtils.getCrud("view"),h=function(){var e=!a;x.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:h,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(Q.List,{data:d,name:u.getName("list"),click:function(e){u.changeValue(e.value),h()},children:l.jsx(Q.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,s,d=e.scope,p=d.crud,f=d.original,g=r.Utils.nvl(f.cols,1),x=Math.floor(100/g)+"%",h=r.Utils.nvl(d.getItems(),[]),y=null==(n={repeat:F,list:B})?void 0:n[f.type],m=r.ComponentUtils.getDefine(e,"add"),j=f.hideAddWhenEmpty,v=function(){if(!r.Utils.isEmpty(h))return l.jsx(l.Fragment,{});var e=d.attr("empty","Sem registro");return e?"string"==typeof e?l.jsx(i.Text,{style:d.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,{})},b=function(n){var a=n.item,o=n.index,s=""+d.key("row",o),p=t.useState(r.ScopeUtils.create({parent:d,name:s,crud:d.crud,index:o,type:"row",data:a}))[0],h=function(e){var t=d.getStyle("row",c({},e,y.row));return g>0&&(t.width=x),t};return f.click?l.jsx(i.TouchableHighlight,{style:h(),underlayColor:"transparent",onPress:function(e){e.stopPropagation(),function(e){d.call("click",{value:e,item:e,edit:!0})}(a)},children:l.jsx(u,{scope:p,children:e.children})},"k-"+o):l.jsx(i.View,{style:h(),children:l.jsx(u,{scope:p,children:e.children})},"k-"+o)};return l.jsxs(l.Fragment,{children:[!1!==f.search&&l.jsx(Q.Text,{placeholder:"Pesquisar...",field:"query",crud:p,right:l.jsx(o.Ionicons,{name:"search",size:20,color:"#888"})}),l.jsxs(i.View,{style:(a={},s=d.getStyle("container",c({},a,y.container)),g>1&&(s=c({},s,{flexDirection:"row",flexWrap:"wrap"})),s),children:[l.jsx(v,{}),h.map((function(e,t){return l.jsx(b,{index:t,item:e})})),(!r.Utils.isEmpty(h)||!0!==j)&&l.jsx(l.Fragment,{children:m})]})]})}var B=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"}}),F=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 P(e){var t=e.scope;return l.jsx(l.Fragment,{children:l.jsx(u,{scope:t,crud:t.crud,children:e.children})})}function L(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({},R.text);return s&&(u.color="#ffffff"),r.Utils.isEmpty(e.children)?l.jsx(i.Text,{style:u,children:a.label}):l.jsx(P,{scope:n,item:a.object,index:o,children:e.children})},g=function(e){var t=c({},R.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 R=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 z(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"},x={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)},h=function(e){n.changeValue(p+e),d(++u)},y=function(e,t){var r=c({},x[e],t);return n.getStyle(e,r)};return l.jsxs(l.Fragment,{children:[l.jsx(i.TouchableHighlight,{underlayColor:"transparent",onPress:function(){h(-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(){h(1)},style:y("addButton"),children:l.jsx(o.Ionicons,{size:30,style:y("buttonIcon"),name:"add"})})]})}function W(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,x=g.getLabel(),h=r.useTheme(),y=function(e,t){var n=c({},q[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(h.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:x}),!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 q=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 O(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",E.container),children:l.jsx(i.ScrollView,{keyboardShouldPersistTaps:"handled",contentContainerStyle:n.getStyle("contentContainer",{}),style:n.getStyle("scroll",E.scroll),children:l.jsx(u,{scope:n,children:a})})})]})}var E=i.StyleSheet.create({scroll:{padding:10},container:{backgroundColor:"primary"},view:{backgroundColor:"primary"}}),H=t.createContext({});function N(e){var n,a,s=t.useContext(H),d=r.Utils.nvl(e.theme,null==s?void 0:s.theme),g=r.Utils.nvl(e.crud,null==s?void 0:s.crud),x=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],B=I[1];g=x.crud;var F=x.getOptions(),P=x.original,R=t.useRef(null);x.update=function(){T(++S)},x.updateElement=function(){T(++S)};var q=function(){var e=P.custom;return e?l.jsx(N,"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(x.is("type","dummy"))return l.jsx(l.Fragment,{children:x.getDisplayValue()});var E=function(e){var t=e.target.value;x.isType("integer","int","number")?t=parseInt(t):x.isType("decimal")&&(t=parseFloat(t)),x.isType("select","complete")&&(t=x.getSelectedItem(t)),x.changeValue(t),x.update()},A=function(e){x.call("click")},X={scope:x,crud:g,onChange:E};x.isType("password")&&(X.type="password");var _=function(){return!(x.isInput()||r.Utils.isEmpty(e.children)&&r.Utils.isEmpty(e.elements))},Q=x.is("type","text","number","phone","postalCode","money","password","email"),J=function(e){var t,n=r.Utils.nvl(P.type,"none"),i=r.Utils.nvl(e,"root"),l=c({},G[i]),a=_();return e||a||(l=c({},l)),x.isInput()&&(l=c({},l,M.input[i])),l=c({},l,null==M||null==(t=M[n])?void 0:t[i]),a&&e&&(l=c({},l,K[e])),c({},l,x.getStyle(e,l))},Y=J("element"),Z={required:x.isRequired(),size:"small",scope:x,crud:g,style:Y,placeholder:x.attr("placeholder","Digite aqui")};x.error=function(e){V=e,B(e)},null!=(n=P.list)&&n.url||null!=(a=P.load)&&a.url||x.start(),t.useEffect((function(){x.start()}));var $=function(){return"string"==typeof P.icon?l.jsx(o.Ionicons,{name:P.icon,style:x.getStyle("icon")}):l.jsx(l.Fragment,{children:P.icon})};if(x.open=function(e){i.Linking.openURL(e.url)},t.useLayoutEffect((function(){if(null!=R&&R.current&&x.is("type","card","list","tabs","stepper")){var e=null==R?void 0:R.current;if(null!=e&&e.classList){var t=r.HtmlUtils.getBGColor(e);e.classList.add("rgb(255, 255, 255)"===t?"ui-dark":"ui-light")}}})),!x.isRendered()||x.is("type","define"))return l.jsx(l.Fragment,{});var ee=i.View,te={};return!x.isType("input","grid","list","repeat")&&P.click&&(ee=i.TouchableHighlight,te.underlayColor="transparent",te.onPress=A),l.jsx(H.Provider,{value:{crud:g,theme:d},children:l.jsx(ee,c({ref:R,style:J()},te,{children:l.jsxs(l.Fragment,{children:[void 0!==P.label&&!1!==P.label&&!x.isType("button","dialog","modal")&&l.jsx(i.Text,{style:J("label"),children:x.getLabel()}),!_()&&l.jsxs(l.Fragment,{children:[l.jsxs(i.View,{style:J("inner"),children:[x.is("type","button")&&l.jsxs(v,c({},Z,{onClick:A,variant:x.attr("variant","outlined"),children:[P.icon&&l.jsx($,{}),P.label&&l.jsx(i.Text,{style:x.getPart("label","button"),children:x.getLabel()})]})),x.is("type","icon")&&l.jsx(j,c({},Z,{onClick:A,variant:x.attr("variant","outlined"),children:x.getDisplayValue()})),x.is("type","link")&&l.jsxs(y,c({},Z,{onClick:A,variant:x.attr("variant","outlined"),children:[P.icon&&l.jsx($,{}),P.label&&l.jsx(i.Text,{style:x.getPart("label","link"),children:x.getLabel()})]})),Q&&l.jsx(U,c({},X,Z,{InputProps:c({},P.inputProps)})),x.is("type","complete","autocomplete")&&l.jsx(h,{scope:x,defaultsInput:X,defaultsUI:Z}),x.is("type","quantity")&&l.jsx(z,{scope:x,defaultsInput:X,defaultsUI:Z}),x.is("type","checkbox","boolean","switch")&&l.jsx(w,c({checked:!0===x.getValue()},X,{onChange:function(){var e=x.getValue();E({target:{value:!(!0===e)}})}})),x.is("type","select")&&l.jsx(b,c({},X,Z,{value:x.getSelectedValue()})),x.is("type","toggle")&&l.jsx(L,c({},X,Z,{value:x.getSelectedValue()})),x.is("type","radio")&&l.jsx(k,c({},X,Z,{row:!0,children:F.map((function(e,t){return l.jsx(C,{control:l.jsx(k,c({},Z)),label:e.label,value:e.value},"i"+t)}))})),x.is("type","custom")&&l.jsx(q,{}),x.is("type","column")&&l.jsxs(l.Fragment,{children:[x.is("format","img")&&l.jsx(i.Image,{source:x.getDisplayValue()}),x.is("format","icon")&&l.jsx(j,{scope:x,crud:g}),!x.is("format","icon","img")&&l.jsx(i.Text,{children:x.getDisplayValue()})]}),x.is("type","output","value")&&l.jsx(i.Text,{style:J("value"),children:x.getDisplayValue()})]}),V&&l.jsx(i.View,{style:J("error"),children:V})]}),x.isType("list","repeat")&&l.jsx(D,c({},e,{scope:x,crud:g})),x.isType("dialog")&&l.jsx(W,c({},e,{scope:x,crud:g})),x.isType("chart")&&l.jsx(f,c({},e,{scope:x,crud:g})),x.isType("tabs")&&l.jsx(p,c({},e,{scope:x,crud:g})),x.isType("view")&&l.jsx(O,c({},e,{scope:x,crud:g})),!x.isType("tabs","view","grid","list","define","repeat","modal","dialog","chart")&&l.jsx(u,c({},e,{scope:x,crud:g,style:J("inner")}))]})}))})}var A={backgroundColor:"white",padding:16,borderRadius:10,width:"100%",shadowColor:"#888",shadowOffset:{width:0,height:1},shadowOpacity:.25,shadowRadius:3.84,elevation:3},M={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}}};M.card=i.StyleSheet.create({root:c({},A),inner:{flex:1,width:"100%",paddingBottom:10,paddingTop:5,alignSelf:"flex-start",flexDirection:"row",flexWrap:"wrap",gap:10}}),M.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"}}),M.quantity={inner:c({},A,{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"})},M.toggle=i.StyleSheet.create({inner:c({},A,{flex:1,width:"100%",gap:10,justifyContent:"center",flexDirection:"row",paddingHorizontal:10,paddingVertical:0,alignSelf:"flex-start",flexWrap:"nowrap"})});var G=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%"}}),K=i.StyleSheet.create({root:{gap:10},label:{width:"100%",fontWeight:500,fontSize:24}});function X(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 _=["type"],Q={List:function(e){return l.jsx(N,c({},e,{type:"list"}))},Row:function(e){return l.jsx(N,c({},e,{type:"row"}))},Value:function(e){return l.jsx(N,c({},e,{type:"value"}))},Label:function(e){return l.jsx(N,c({},e,{type:"label"}))},Repeat:function(e){return l.jsx(N,c({},e,{type:"repeat",props:{search:!1}}))},Define:function(e){return l.jsx(N,c({},e,{type:"define"}))},Include:function(e){return l.jsx(X,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,_);return l.jsx(N,c({},t,{type:"column"}))},Input:function(e){return l.jsx(N,c({},e))},Text:function(e){return l.jsx(N,c({},e,{type:"text"}))},Email:function(e){return l.jsx(N,c({},e,{type:"email"}))},Button:function(e){return l.jsx(N,c({},e,{type:"button"}))},Link:function(e){return l.jsx(N,c({},e,{type:"link"}))},Icon:function(e){return l.jsx(N,c({},e,{type:"icon"}))},Output:function(e){return l.jsx(N,c({},e,{type:"output"}))},Form:function(e){return l.jsx(N,c({},e,{type:"form"}))},Crud:function(e){return l.jsx(N,c({},e,{type:"crud"}))},View:function(e){return l.jsx(N,c({},e,{type:"view",transient:!0}))},Bottom:function(e){return l.jsx(N,c({},e,{type:"bottom"}))},Dialog:function(e){return l.jsx(N,c({},e,{type:"dialog"}))},Content:function(e){return l.jsx(N,c({},e,{type:"content"}))},Top:function(e){return l.jsx(N,c({},e,{type:"top"}))},Card:function(e){return l.jsx(N,c({},e,{type:"card"}))},Tab:function(e){return l.jsx(N,c({},e,{type:"tab"}))},Tabs:function(e){return l.jsx(N,c({},e,{type:"tabs"}))},Step:function(e){return l.jsx(N,c({},e,{type:"tab",layout:"step"}))},Stepper:function(e){return l.jsx(N,c({},e,{type:"tabs",layout:"stepper"}))},Money:function(e){return l.jsx(N,c({},e,{type:"money"}))},Chart:function(e){return l.jsx(N,c({},e,{type:"chart"}))},Password:function(e){return l.jsx(N,c({},e,{type:"password"}))},Complete:function(e){return l.jsx(N,c({},e,{type:"complete"}))},Checkbox:function(e){return l.jsx(N,c({},e,{type:"switch"}))},Switch:function(e){return l.jsx(N,c({},e,{type:"switch"}))},Radio:function(e){return l.jsx(N,c({},e,{type:"radio"}))},Select:function(e){return l.jsx(N,c({},e,{type:"select"}))},Toggle:function(e){return l.jsx(N,c({},e,{type:"toggle"}))},Entity:function(e){return l.jsx(N,c({},e,{type:"entity"}))},Element:function(e){return l.jsx(N,c({},e,{type:"element"}))},Quantity:function(e){return l.jsx(N,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=Q;
|
|
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,x,g=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}))},h=function(){return l.jsx(l.Fragment,e.elements?{children:Object.entries(e.elements).map((function(e,t){return l.jsx(N,c({crud:o},e[1]))}))}:{children:n.Children.map(e.children,(function(e){return l.jsx(g,{child:e})}))})};return e.transient?l.jsx(h,{}):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,x=r.Utils.nvl(f,"root"),c({},d[x],e.style,a.getStyle(f))),children:l.jsx(h,{})})})}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(),x=0,g=[],h=t.useState(null),y=h[0],m=h[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&&g.push(c({},a,{child:e,element:a,original:n,index:x++,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(g[s],!1);var S=function(e){j(g[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:g.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(Q.Output,{space:6,layout:"left",children:l.jsx(Q.Include,c({},e,{transient:!0,name:"left",default:l.jsx(Q.Button,{rendered:s>0,icon:l.jsx(a,{}),click:function(){S(-1)}})}))}),l.jsx(Q.Output,{space:6,layout:"right",children:l.jsx(Q.Include,c({},e,{transient:!0,name:"right",default:l.jsx(Q.Button,{rendered:s<g.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 x(e){return l.jsx(i.TouchableOpacity,{onPress:function(){i.Linking.openURL("https://reactnative.dev/")},children:l.jsx(i.Text,{style:g.link,children:"Clique aqui para acessar o React Native"})})}var g={link:{}};function h(e){return l.jsx(l.Fragment,{children:l.jsx(x,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(),x=r.useTheme(),g=r.ViewUtils.getCrud("view"),h=function(){var e=!a;g.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:h,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:x.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(Q.List,{data:d,name:u.getName("list"),click:function(e){u.changeValue(e.value),h()},children:l.jsx(Q.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],x=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),x(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=e.scope,i=e.item,a=e.index,o=""+n.key("row",a),s=t.useState(r.ScopeUtils.create({parent:n,name:o,crud:n.crud,index:a,type:"row",data:i}))[0];return l.jsx(l.Fragment,{children:l.jsx(u,{scope:s,crud:s.crud,children:e.children})})}function B(e){var t,n,a=e.scope,s=a.crud,u=a.original,d=r.Utils.nvl(u.cols,1),p=Math.floor(100/d)+"%",f=r.Utils.nvl(a.getItems(),[]),x=null==(t={repeat:P,list:F})?void 0:t[u.type],g=r.ComponentUtils.getDefine(e,"add"),h=u.hideAddWhenEmpty,y=function(e,t){return a.getStyle(e,c({},t,x[e]))},m=function(e){var t=y("row",{});return d>0&&(t.width=p),t},j=function(){if(!r.Utils.isEmpty(f))return l.jsx(l.Fragment,{});var e=a.attr("empty","Sem registro");return e?"string"==typeof e?l.jsx(i.Text,{style:a.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,{})},v=function(e){var t=e.item,n=e.index,r=e.children;return u.click?l.jsx(i.TouchableHighlight,{style:m(),underlayColor:"transparent",onPress:function(e){e.stopPropagation(),function(e){a.call("click",{value:e,item:e,edit:!0})}(t)},children:r},"k-"+n):l.jsx(i.View,{style:m(),children:r},"k-"+n)};return l.jsxs(l.Fragment,{children:[!1!==u.search&&l.jsx(Q.Text,{placeholder:"Pesquisar...",field:"query",crud:s,right:l.jsx(o.Ionicons,{name:"search",size:20,color:"#888"})}),l.jsxs(i.View,{style:(n=y("container",{}),d>1&&(n=c({},n,{flexDirection:"row",flexWrap:"wrap"})),n),children:[l.jsx(j,{}),f.map((function(t,n){return l.jsx(v,{index:n,item:t,children:l.jsx(D,{scope:a,item:t,index:n,children:e.children})})})),(!r.Utils.isEmpty(f)||!0!==h)&&l.jsx(l.Fragment,{children:g})]})]})}var F=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"}}),P=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 L(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({},R.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})},x=function(e){var t=c({},R.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:x(e),onPress:function(t){!function(e){n.changeValue(e.object),d(++u)}(e)},children:l.jsx(f,{item:e,index:t})},"k-"+t)}))})}var R=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 z(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 x={padding:10,alignItems:"center",height:44,width:44,textAlign:"center",verticalAling:"middle",borderRadius:24,backgroundColor:f,color:"#ffffff",justifyContent:"center"},g={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:x,addButton:c({},x),delButton:c({},x)},h=function(e){n.changeValue(p+e),d(++u)},y=function(e,t){var r=c({},g[e],t);return n.getStyle(e,r)};return l.jsxs(l.Fragment,{children:[l.jsx(i.TouchableHighlight,{underlayColor:"transparent",onPress:function(){h(-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(){h(1)},style:y("addButton"),children:l.jsx(o.Ionicons,{size:30,style:y("buttonIcon"),name:"add"})})]})}function W(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"),x=e.scope,g=x.getLabel(),h=r.useTheme(),y=function(e,t){var n=c({},q[e],t);return c({},x.getStyle(e,n))},m=function(){x.close({scope:x,crud:x.currentDialog,event:{}})},j=function(e){o(a=e)};x.update=function(){p(++d)},x.show=function(e){var t=e.crud,n=x.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:x},l));f.dialog=s,x.currentDialog=s,j(!0)},x.hide=function(e){var t;f.dialog=r.Utils.nvl(x.currentDialog.dialog,null),x.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(h.colors.primary)}),[a]);var v=x.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:g}),!r.Utils.isEmpty(b)&&l.jsx(u,{scope:x,crud:x.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:x,crud:x.currentDialog,children:e.children})})})]})})}var q=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 O(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",E.container),children:l.jsx(i.ScrollView,{keyboardShouldPersistTaps:"handled",contentContainerStyle:n.getStyle("contentContainer",{}),style:n.getStyle("scroll",E.scroll),children:l.jsx(u,{scope:n,children:a})})})]})}var E=i.StyleSheet.create({scroll:{padding:10},container:{backgroundColor:"primary"},view:{backgroundColor:"primary"}}),H=t.createContext({});function N(e){var n,a,s=t.useContext(H),d=r.Utils.nvl(e.theme,null==s?void 0:s.theme),x=r.Utils.nvl(e.crud,null==s?void 0:s.crud),g=t.useState(r.ScopeUtils.create(c({crud:x},e,{theme:d})))[0],m=t.useState(0),S=m[0],T=m[1],I=t.useState(null),V=I[0],D=I[1];x=g.crud;var F=g.getOptions(),P=g.original,R=t.useRef(null);g.update=function(){T(++S)},g.updateElement=function(){T(++S)};var q=function(){var e=P.custom;return e?l.jsx(N,"string"==typeof e?{element:{value:e,type:"dummy"},crud:x}:c({type:e.type,tag:e.type},e.props,{crud:x})):l.jsx(l.Fragment,{})};if(g.is("type","dummy"))return l.jsx(l.Fragment,{children:g.getDisplayValue()});var E=function(e){var t=e.target.value;g.isType("integer","int","number")?t=parseInt(t):g.isType("decimal")&&(t=parseFloat(t)),g.isType("select","complete")&&(t=g.getSelectedItem(t)),g.changeValue(t),g.update()},A=function(e){g.call("click")},X={scope:g,crud:x,onChange:E};g.isType("password")&&(X.type="password");var _=function(){return!(g.isInput()||r.Utils.isEmpty(e.children)&&r.Utils.isEmpty(e.elements))},Q=g.is("type","text","number","phone","postalCode","money","password","email"),J=function(e){var t,n=r.Utils.nvl(P.type,"none"),i=r.Utils.nvl(e,"root"),l=c({},G[i]),a=_();return e||a||(l=c({},l)),g.isInput()&&(l=c({},l,M.input[i])),l=c({},l,null==M||null==(t=M[n])?void 0:t[i]),a&&e&&(l=c({},l,K[e])),c({},l,g.getStyle(e,l))},Y=J("element"),Z={required:g.isRequired(),size:"small",scope:g,crud:x,style:Y,placeholder:g.attr("placeholder","Digite aqui")};g.error=function(e){V=e,D(e)},null!=(n=P.list)&&n.url||null!=(a=P.load)&&a.url||g.start(),t.useEffect((function(){g.start()}));var $=function(){return"string"==typeof P.icon?l.jsx(o.Ionicons,{name:P.icon,style:g.getStyle("icon")}):l.jsx(l.Fragment,{children:P.icon})};if(g.open=function(e){i.Linking.openURL(e.url)},t.useLayoutEffect((function(){if(null!=R&&R.current&&g.is("type","card","list","tabs","stepper")){var e=null==R?void 0:R.current;if(null!=e&&e.classList){var t=r.HtmlUtils.getBGColor(e);e.classList.add("rgb(255, 255, 255)"===t?"ui-dark":"ui-light")}}})),!g.isRendered()||g.is("type","define"))return l.jsx(l.Fragment,{});var ee=i.View,te={};return!g.isType("input","grid","list","repeat")&&P.click&&(ee=i.TouchableHighlight,te.underlayColor="transparent",te.onPress=A),l.jsx(H.Provider,{value:{crud:x,theme:d},children:l.jsx(ee,c({ref:R,style:J()},te,{children:l.jsxs(l.Fragment,{children:[void 0!==P.label&&!1!==P.label&&!g.isType("button","dialog","modal")&&l.jsx(i.Text,{style:J("label"),children:g.getLabel()}),!_()&&l.jsxs(l.Fragment,{children:[l.jsxs(i.View,{style:J("inner"),children:[g.is("type","button")&&l.jsxs(v,c({},Z,{onClick:A,variant:g.attr("variant","outlined"),children:[P.icon&&l.jsx($,{}),P.label&&l.jsx(i.Text,{style:g.getPart("label","button"),children:g.getLabel()})]})),g.is("type","icon")&&l.jsx(j,c({},Z,{onClick:A,variant:g.attr("variant","outlined"),children:g.getDisplayValue()})),g.is("type","link")&&l.jsxs(y,c({},Z,{onClick:A,variant:g.attr("variant","outlined"),children:[P.icon&&l.jsx($,{}),P.label&&l.jsx(i.Text,{style:g.getPart("label","link"),children:g.getLabel()})]})),Q&&l.jsx(U,c({},X,Z,{InputProps:c({},P.inputProps)})),g.is("type","complete","autocomplete")&&l.jsx(h,{scope:g,defaultsInput:X,defaultsUI:Z}),g.is("type","quantity")&&l.jsx(z,{scope:g,defaultsInput:X,defaultsUI:Z}),g.is("type","checkbox","boolean","switch")&&l.jsx(w,c({checked:!0===g.getValue()},X,{onChange:function(){var e=g.getValue();E({target:{value:!(!0===e)}})}})),g.is("type","select")&&l.jsx(b,c({},X,Z,{value:g.getSelectedValue()})),g.is("type","toggle")&&l.jsx(L,c({},X,Z,{value:g.getSelectedValue()})),g.is("type","radio")&&l.jsx(k,c({},X,Z,{row:!0,children:F.map((function(e,t){return l.jsx(C,{control:l.jsx(k,c({},Z)),label:e.label,value:e.value},"i"+t)}))})),g.is("type","custom")&&l.jsx(q,{}),g.is("type","column")&&l.jsxs(l.Fragment,{children:[g.is("format","img")&&l.jsx(i.Image,{source:g.getDisplayValue()}),g.is("format","icon")&&l.jsx(j,{scope:g,crud:x}),!g.is("format","icon","img")&&l.jsx(i.Text,{children:g.getDisplayValue()})]}),g.is("type","output","value")&&l.jsx(i.Text,{style:J("value"),children:g.getDisplayValue()})]}),V&&l.jsx(i.View,{style:J("error"),children:V})]}),g.isType("list","repeat")&&l.jsx(B,c({},e,{scope:g,crud:x})),g.isType("dialog")&&l.jsx(W,c({},e,{scope:g,crud:x})),g.isType("chart")&&l.jsx(f,c({},e,{scope:g,crud:x})),g.isType("tabs")&&l.jsx(p,c({},e,{scope:g,crud:x})),g.isType("view")&&l.jsx(O,c({},e,{scope:g,crud:x})),!g.isType("tabs","view","grid","list","define","repeat","modal","dialog","chart")&&l.jsx(u,c({},e,{scope:g,crud:x,style:J("inner")}))]})}))})}var A={backgroundColor:"white",padding:16,borderRadius:10,width:"100%",shadowColor:"#888",shadowOffset:{width:0,height:1},shadowOpacity:.25,shadowRadius:3.84,elevation:3},M={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}}};M.card=i.StyleSheet.create({root:c({},A),inner:{flex:1,width:"100%",paddingBottom:10,paddingTop:5,alignSelf:"flex-start",flexDirection:"row",flexWrap:"wrap",gap:10}}),M.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"}}),M.quantity={inner:c({},A,{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"})},M.toggle=i.StyleSheet.create({inner:c({},A,{flex:1,width:"100%",gap:10,justifyContent:"center",flexDirection:"row",paddingHorizontal:10,paddingVertical:0,alignSelf:"flex-start",flexWrap:"nowrap"})});var G=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%"}}),K=i.StyleSheet.create({root:{gap:10},label:{width:"100%",fontWeight:500,fontSize:24}});function X(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 _=["type"],Q={List:function(e){return l.jsx(N,c({},e,{type:"list"}))},Row:function(e){return l.jsx(N,c({},e,{type:"row"}))},Value:function(e){return l.jsx(N,c({},e,{type:"value"}))},Label:function(e){return l.jsx(N,c({},e,{type:"label"}))},Repeat:function(e){return l.jsx(N,c({},e,{type:"repeat",props:{search:!1}}))},Define:function(e){return l.jsx(N,c({},e,{type:"define"}))},Include:function(e){return l.jsx(X,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,_);return l.jsx(N,c({},t,{type:"column"}))},Input:function(e){return l.jsx(N,c({},e))},Text:function(e){return l.jsx(N,c({},e,{type:"text"}))},Email:function(e){return l.jsx(N,c({},e,{type:"email"}))},Button:function(e){return l.jsx(N,c({},e,{type:"button"}))},Link:function(e){return l.jsx(N,c({},e,{type:"link"}))},Icon:function(e){return l.jsx(N,c({},e,{type:"icon"}))},Output:function(e){return l.jsx(N,c({},e,{type:"output"}))},Form:function(e){return l.jsx(N,c({},e,{type:"form"}))},Crud:function(e){return l.jsx(N,c({},e,{type:"crud"}))},View:function(e){return l.jsx(N,c({},e,{type:"view",transient:!0}))},Bottom:function(e){return l.jsx(N,c({},e,{type:"bottom"}))},Dialog:function(e){return l.jsx(N,c({},e,{type:"dialog"}))},Content:function(e){return l.jsx(N,c({},e,{type:"content"}))},Top:function(e){return l.jsx(N,c({},e,{type:"top"}))},Card:function(e){return l.jsx(N,c({},e,{type:"card"}))},Tab:function(e){return l.jsx(N,c({},e,{type:"tab"}))},Tabs:function(e){return l.jsx(N,c({},e,{type:"tabs"}))},Step:function(e){return l.jsx(N,c({},e,{type:"tab",layout:"step"}))},Stepper:function(e){return l.jsx(N,c({},e,{type:"tabs",layout:"stepper"}))},Money:function(e){return l.jsx(N,c({},e,{type:"money"}))},Chart:function(e){return l.jsx(N,c({},e,{type:"chart"}))},Password:function(e){return l.jsx(N,c({},e,{type:"password"}))},Complete:function(e){return l.jsx(N,c({},e,{type:"complete"}))},Checkbox:function(e){return l.jsx(N,c({},e,{type:"switch"}))},Switch:function(e){return l.jsx(N,c({},e,{type:"switch"}))},Radio:function(e){return l.jsx(N,c({},e,{type:"radio"}))},Select:function(e){return l.jsx(N,c({},e,{type:"select"}))},Toggle:function(e){return l.jsx(N,c({},e,{type:"toggle"}))},Entity:function(e){return l.jsx(N,c({},e,{type:"entity"}))},Element:function(e){return l.jsx(N,c({},e,{type:"element"}))},Quantity:function(e){return l.jsx(N,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=Q;
|
|
2
2
|
//# sourceMappingURL=react-crud-mobile.cjs.production.min.js.map
|