UNPKG

qvt-components

Version:

This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).

3 lines (2 loc) 19.2 kB
import{jsxs as e,jsx as t}from"react/jsx-runtime";import{Slider as r,TextArea as n,Switch as o,Select as i,Checkbox as a,FormControl as s,Input as c,Heading as l,Button as u}from"native-base";import f,{Component as d}from"react";import{Animated as p,I18nManager as y,PanResponder as b,TouchableOpacity as m,Image as h,Text as v,View as g}from"react-native";function S(){return S=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},S.apply(this,arguments)}const x=n=>e(r,S({},n,{children:[t(r.Track,{children:t(r.FilledTrack,{},void 0)},void 0),t(r.Thumb,{},void 0)]}),void 0),O=e=>t(n,S({},e),void 0),w=e=>t(o,S({},e),void 0),C=e=>t(i.Item,S({},e),void 0),j=e=>t(i,S({},e),void 0),E=r=>{const[n,o]=f.useState([]);return e(a.Group,{onChange:o,value:n,children:[t(a,{value:"one",my:2,children:"Item 1"},void 0),t(a,{value:"two"},void 0)]},void 0)},P=e=>t(s,S({},e),void 0),I=e=>t(c,S({},e),void 0),T=e=>t(l,S({},e),void 0),$=e=>t(u,S({colorScheme:"primary",variant:"solid"},e),void 0);function R(e){var t={exports:{}};return e(t,t.exports),t.exports}var k="function"==typeof Symbol&&Symbol.for,_=k?Symbol.for("react.element"):60103,D=k?Symbol.for("react.portal"):60106,N=k?Symbol.for("react.fragment"):60107,V=k?Symbol.for("react.strict_mode"):60108,M=k?Symbol.for("react.profiler"):60114,A=k?Symbol.for("react.provider"):60109,L=k?Symbol.for("react.context"):60110,W=k?Symbol.for("react.async_mode"):60111,z=k?Symbol.for("react.concurrent_mode"):60111,F=k?Symbol.for("react.forward_ref"):60112,H=k?Symbol.for("react.suspense"):60113,q=k?Symbol.for("react.suspense_list"):60120,B=k?Symbol.for("react.memo"):60115,U=k?Symbol.for("react.lazy"):60116,G=k?Symbol.for("react.block"):60121,J=k?Symbol.for("react.fundamental"):60117,Y=k?Symbol.for("react.responder"):60118,X=k?Symbol.for("react.scope"):60119;function K(e){if("object"==typeof e&&null!==e){var t=e.$$typeof;switch(t){case _:switch(e=e.type){case W:case z:case N:case M:case V:case H:return e;default:switch(e=e&&e.$$typeof){case L:case F:case U:case B:case A:return e;default:return t}}case D:return t}}}function Q(e){return K(e)===z}var Z={AsyncMode:W,ConcurrentMode:z,ContextConsumer:L,ContextProvider:A,Element:_,ForwardRef:F,Fragment:N,Lazy:U,Memo:B,Portal:D,Profiler:M,StrictMode:V,Suspense:H,isAsyncMode:function(e){return Q(e)||K(e)===W},isConcurrentMode:Q,isContextConsumer:function(e){return K(e)===L},isContextProvider:function(e){return K(e)===A},isElement:function(e){return"object"==typeof e&&null!==e&&e.$$typeof===_},isForwardRef:function(e){return K(e)===F},isFragment:function(e){return K(e)===N},isLazy:function(e){return K(e)===U},isMemo:function(e){return K(e)===B},isPortal:function(e){return K(e)===D},isProfiler:function(e){return K(e)===M},isStrictMode:function(e){return K(e)===V},isSuspense:function(e){return K(e)===H},isValidElementType:function(e){return"string"==typeof e||"function"==typeof e||e===N||e===z||e===M||e===V||e===H||e===q||"object"==typeof e&&null!==e&&(e.$$typeof===U||e.$$typeof===B||e.$$typeof===A||e.$$typeof===L||e.$$typeof===F||e.$$typeof===J||e.$$typeof===Y||e.$$typeof===X||e.$$typeof===G)},typeOf:K},ee=R(function(e,t){"production"!==process.env.NODE_ENV&&function(){var e="function"==typeof Symbol&&Symbol.for,r=e?Symbol.for("react.element"):60103,n=e?Symbol.for("react.portal"):60106,o=e?Symbol.for("react.fragment"):60107,i=e?Symbol.for("react.strict_mode"):60108,a=e?Symbol.for("react.profiler"):60114,s=e?Symbol.for("react.provider"):60109,c=e?Symbol.for("react.context"):60110,l=e?Symbol.for("react.async_mode"):60111,u=e?Symbol.for("react.concurrent_mode"):60111,f=e?Symbol.for("react.forward_ref"):60112,d=e?Symbol.for("react.suspense"):60113,p=e?Symbol.for("react.suspense_list"):60120,y=e?Symbol.for("react.memo"):60115,b=e?Symbol.for("react.lazy"):60116,m=e?Symbol.for("react.block"):60121,h=e?Symbol.for("react.fundamental"):60117,v=e?Symbol.for("react.responder"):60118,g=e?Symbol.for("react.scope"):60119;function S(e){if("object"==typeof e&&null!==e){var t=e.$$typeof;switch(t){case r:var p=e.type;switch(p){case l:case u:case o:case a:case i:case d:return p;default:var m=p&&p.$$typeof;switch(m){case c:case f:case b:case y:case s:return m;default:return t}}case n:return t}}}var x=u,O=c,w=s,C=r,j=f,E=o,P=b,I=y,T=n,$=a,R=i,k=d,_=!1;function D(e){return S(e)===u}t.AsyncMode=l,t.ConcurrentMode=x,t.ContextConsumer=O,t.ContextProvider=w,t.Element=C,t.ForwardRef=j,t.Fragment=E,t.Lazy=P,t.Memo=I,t.Portal=T,t.Profiler=$,t.StrictMode=R,t.Suspense=k,t.isAsyncMode=function(e){return _||(_=!0,console.warn("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 17+. Update your code to use ReactIs.isConcurrentMode() instead. It has the exact same API.")),D(e)||S(e)===l},t.isConcurrentMode=D,t.isContextConsumer=function(e){return S(e)===c},t.isContextProvider=function(e){return S(e)===s},t.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===r},t.isForwardRef=function(e){return S(e)===f},t.isFragment=function(e){return S(e)===o},t.isLazy=function(e){return S(e)===b},t.isMemo=function(e){return S(e)===y},t.isPortal=function(e){return S(e)===n},t.isProfiler=function(e){return S(e)===a},t.isStrictMode=function(e){return S(e)===i},t.isSuspense=function(e){return S(e)===d},t.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===o||e===u||e===a||e===i||e===d||e===p||"object"==typeof e&&null!==e&&(e.$$typeof===b||e.$$typeof===y||e.$$typeof===s||e.$$typeof===c||e.$$typeof===f||e.$$typeof===h||e.$$typeof===v||e.$$typeof===g||e.$$typeof===m)},t.typeOf=S}()}),te=R(function(e){e.exports="production"===process.env.NODE_ENV?Z:ee}),re=Object.getOwnPropertySymbols,ne=Object.prototype.hasOwnProperty,oe=Object.prototype.propertyIsEnumerable;function ie(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}var ae=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},r=0;r<10;r++)t["_"+String.fromCharCode(r)]=r;var n=Object.getOwnPropertyNames(t).map(function(e){return t[e]});if("0123456789"!==n.join(""))return!1;var o={};return"abcdefghijklmnopqrst".split("").forEach(function(e){o[e]=e}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},o)).join("")}catch(e){return!1}}()?Object.assign:function(e,t){for(var r,n,o=ie(e),i=1;i<arguments.length;i++){for(var a in r=Object(arguments[i]))ne.call(r,a)&&(o[a]=r[a]);if(re){n=re(r);for(var s=0;s<n.length;s++)oe.call(r,n[s])&&(o[n[s]]=r[n[s]])}}return o},se="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED",ce=function(){};if("production"!==process.env.NODE_ENV){var le=se,ue={},fe=Function.call.bind(Object.prototype.hasOwnProperty);ce=function(e){var t="Warning: "+e;"undefined"!=typeof console&&console.error(t);try{throw new Error(t)}catch(e){}}}function de(e,t,r,n,o){if("production"!==process.env.NODE_ENV)for(var i in e)if(fe(e,i)){var a;try{if("function"!=typeof e[i]){var s=Error((n||"React class")+": "+r+" type `"+i+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[i]+"`.");throw s.name="Invariant Violation",s}a=e[i](t,i,n,r,null,le)}catch(e){a=e}if(!a||a instanceof Error||ce((n||"React class")+": type specification of "+r+" `"+i+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof a+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),a instanceof Error&&!(a.message in ue)){ue[a.message]=!0;var c=o?o():"";ce("Failed "+r+" type: "+a.message+(null!=c?c:""))}}}de.resetWarningCache=function(){"production"!==process.env.NODE_ENV&&(ue={})};var pe=de,ye=Function.call.bind(Object.prototype.hasOwnProperty),be=function(){};function me(){return null}function he(){}function ve(){}"production"!==process.env.NODE_ENV&&(be=function(e){var t="Warning: "+e;"undefined"!=typeof console&&console.error(t);try{throw new Error(t)}catch(e){}}),ve.resetWarningCache=he;var ge=R(function(e){e.exports="production"!==process.env.NODE_ENV?function(e,t){var r="function"==typeof Symbol&&Symbol.iterator,n="<<anonymous>>",o={array:c("array"),bool:c("boolean"),func:c("function"),number:c("number"),object:c("object"),string:c("string"),symbol:c("symbol"),any:s(me),arrayOf:function(e){return s(function(t,r,n,o,i){if("function"!=typeof e)return new a("Property `"+i+"` of component `"+n+"` has invalid PropType notation inside arrayOf.");var s=t[r];if(!Array.isArray(s))return new a("Invalid "+o+" `"+i+"` of type `"+u(s)+"` supplied to `"+n+"`, expected an array.");for(var c=0;c<s.length;c++){var l=e(s,c,n,o,i+"["+c+"]",se);if(l instanceof Error)return l}return null})},element:s(function(t,r,n,o,i){var s=t[r];return e(s)?null:new a("Invalid "+o+" `"+i+"` of type `"+u(s)+"` supplied to `"+n+"`, expected a single ReactElement.")}),elementType:s(function(e,t,r,n,o){var i=e[t];return te.isValidElementType(i)?null:new a("Invalid "+n+" `"+o+"` of type `"+u(i)+"` supplied to `"+r+"`, expected a single ReactElement type.")}),instanceOf:function(e){return s(function(t,r,o,i,s){return t[r]instanceof e?null:new a("Invalid "+i+" `"+s+"` of type `"+((c=t[r]).constructor&&c.constructor.name?c.constructor.name:n)+"` supplied to `"+o+"`, expected instance of `"+(e.name||n)+"`.");var c})},node:s(function(e,t,r,n,o){return l(e[t])?null:new a("Invalid "+n+" `"+o+"` supplied to `"+r+"`, expected a ReactNode.")}),objectOf:function(e){return s(function(t,r,n,o,i){if("function"!=typeof e)return new a("Property `"+i+"` of component `"+n+"` has invalid PropType notation inside objectOf.");var s=t[r],c=u(s);if("object"!==c)return new a("Invalid "+o+" `"+i+"` of type `"+c+"` supplied to `"+n+"`, expected an object.");for(var l in s)if(ye(s,l)){var f=e(s,l,n,o,i+"."+l,se);if(f instanceof Error)return f}return null})},oneOf:function(e){if(!Array.isArray(e))return"production"!==process.env.NODE_ENV&&be(arguments.length>1?"Invalid arguments supplied to oneOf, expected an array, got "+arguments.length+" arguments. A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).":"Invalid argument supplied to oneOf, expected an array."),me;function t(t,r,n,o,s){for(var c=t[r],l=0;l<e.length;l++)if(i(c,e[l]))return null;var u=JSON.stringify(e,function(e,t){return"symbol"===f(t)?String(t):t});return new a("Invalid "+o+" `"+s+"` of value `"+String(c)+"` supplied to `"+n+"`, expected one of "+u+".")}return s(t)},oneOfType:function(e){if(!Array.isArray(e))return"production"!==process.env.NODE_ENV&&be("Invalid argument supplied to oneOfType, expected an instance of array."),me;for(var t=0;t<e.length;t++){var r=e[t];if("function"!=typeof r)return be("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+d(r)+" at index "+t+"."),me}return s(function(t,r,n,o,i){for(var s=0;s<e.length;s++)if(null==(0,e[s])(t,r,n,o,i,se))return null;return new a("Invalid "+o+" `"+i+"` supplied to `"+n+"`.")})},shape:function(e){return s(function(t,r,n,o,i){var s=t[r],c=u(s);if("object"!==c)return new a("Invalid "+o+" `"+i+"` of type `"+c+"` supplied to `"+n+"`, expected `object`.");for(var l in e){var f=e[l];if(f){var d=f(s,l,n,o,i+"."+l,se);if(d)return d}}return null})},exact:function(e){return s(function(t,r,n,o,i){var s=t[r],c=u(s);if("object"!==c)return new a("Invalid "+o+" `"+i+"` of type `"+c+"` supplied to `"+n+"`, expected `object`.");var l=ae({},t[r],e);for(var f in l){var d=e[f];if(!d)return new a("Invalid "+o+" `"+i+"` key `"+f+"` supplied to `"+n+"`.\nBad object: "+JSON.stringify(t[r],null," ")+"\nValid keys: "+JSON.stringify(Object.keys(e),null," "));var p=d(s,f,n,o,i+"."+f,se);if(p)return p}return null})}};function i(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}function a(e){this.message=e,this.stack=""}function s(e){function t(t,r,o,i,s,c,l){if(i=i||n,c=c||o,l!==se){var u=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");throw u.name="Invariant Violation",u}return null==r[o]?t?new a(null===r[o]?"The "+s+" `"+c+"` is marked as required in `"+i+"`, but its value is `null`.":"The "+s+" `"+c+"` is marked as required in `"+i+"`, but its value is `undefined`."):null:e(r,o,i,s,c)}process;var r=t.bind(null,!1);return r.isRequired=t.bind(null,!0),r}function c(e){return s(function(t,r,n,o,i,s){var c=t[r];return u(c)!==e?new a("Invalid "+o+" `"+i+"` of type `"+f(c)+"` supplied to `"+n+"`, expected `"+e+"`."):null})}function l(t){switch(typeof t){case"number":case"string":case"undefined":return!0;case"boolean":return!t;case"object":if(Array.isArray(t))return t.every(l);if(null===t||e(t))return!0;var n=function(e){var t=e&&(r&&e[r]||e["@@iterator"]);if("function"==typeof t)return t}(t);if(!n)return!1;var o,i=n.call(t);if(n!==t.entries){for(;!(o=i.next()).done;)if(!l(o.value))return!1}else for(;!(o=i.next()).done;){var a=o.value;if(a&&!l(a[1]))return!1}return!0;default:return!1}}function u(e){var t=typeof e;return Array.isArray(e)?"array":e instanceof RegExp?"object":function(e,t){return"symbol"===e||!!t&&("Symbol"===t["@@toStringTag"]||"function"==typeof Symbol&&t instanceof Symbol)}(t,e)?"symbol":t}function f(e){if(null==e)return""+e;var t=u(e);if("object"===t){if(e instanceof Date)return"date";if(e instanceof RegExp)return"regexp"}return t}function d(e){var t=f(e);switch(t){case"array":case"object":return"an "+t;case"boolean":case"date":case"regexp":return"a "+t;default:return t}}return a.prototype=Error.prototype,o.checkPropTypes=pe,o.resetWarningCache=pe.resetWarningCache,o.PropTypes=o,o}(te.isElement):function(){function e(e,t,r,n,o,i){if(i!==se){var a=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw a.name="Invariant Violation",a}}function t(){return e}e.isRequired=e;var r={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:ve,resetWarningCache:he};return r.PropTypes=r,r}()});const Se={button:{flex:1,flexDirection:"row",justifyContent:"center",alignItems:"center"},animated:{borderWidth:0,position:"absolute"}};class xe extends d{constructor(e){super(e),this.responderEnd=(e,t)=>{const{disabled:r,options:n}=this.props,{selected:o}=this.state;if(r)return;const i=this.getSwipeDirection(t);"RIGHT"===i&&o<n.length-1?this.toggleItem(o+1):"LEFT"===i&&o>0&&this.toggleItem(o-1)},this.shouldSetResponder=(e,t)=>1===e.nativeEvent.touches.length&&!(Math.abs(t.dx)<5&&Math.abs(t.dy)<5),this.animate=(e,t)=>{const{animationDuration:r}=this.props;this.animatedValue.setValue(t),p.timing(this.animatedValue,{toValue:e,duration:r,useNativeDriver:!0}).start()},this.toggleItem=(e,t=!0)=>{const{selected:r}=this.state,{options:n,returnObject:o,onPress:i}=this.props;n.length<=1||null===e||isNaN(e)||(this.animate(y.isRTL?-e/n.length:e/n.length,y.isRTL?-r/n.length:r/n.length),t&&i?i(o?n[e]:n[e].value):console.log("Call onPress with value: ",n[e].value),this.setState({selected:e}))};const{initial:t,options:r}=e;this.state={selected:t},this.panResponder=b.create({onStartShouldSetPanResponder:this.shouldSetResponder,onMoveShouldSetPanResponder:this.shouldSetResponder,onPanResponderRelease:this.responderEnd,onPanResponderTerminate:this.responderEnd}),this.animatedValue=new p.Value(t?y.isRTL?-t/r.length:t/r.length:0)}componentDidUpdate(e){const{value:t,disableValueChangeOnPress:r}=this.props;e.value!==t&&this.toggleItem(t,!r)}getSwipeDirection(e){const{dx:t,dy:r,vx:n}=e;return Math.abs(n)>.1&&Math.abs(r)<80?t>0?"RIGHT":"LEFT":null}getBgColor(){const{selected:e}=this.state,{options:t,buttonColor:r}=this.props;return-1===e?"transparent":t[e].activeColor||r}render(){const{style:r,textStyle:n,selectedTextStyle:o,textContainerStyle:i,selectedTextContainerStyle:a,imageStyle:s,textColor:c,selectedColor:l,fontSize:u,backgroundColor:f,borderColor:d,borderRadius:y,borderWidth:b,hasPadding:x,valuePadding:O,height:w,bold:C,disabled:j,buttonMargin:E,options:P}=this.props,{selected:I,sliderWidth:T}=this.state,$=P.map((r,f)=>{const d=I===f;return e(m,{disabled:j,style:[Se.button,d?a:i],onPress:()=>this.toggleItem(f),accessibilityLabel:r.accessibilityLabel,testID:r.testID,children:["function"==typeof r.customIcon?r.customIcon(d):r.customIcon,r.imageIcon&&t(h,{source:r.imageIcon,style:[{height:30,width:30,tintColor:d?l:c},s]},void 0),t(v,{style:[{fontSize:u,fontWeight:C?"bold":"normal",textAlign:"center",color:d?l:c,backgroundColor:"transparent"},d?o:n],numberOfLines:1,children:r.label},void 0)]},f)});return t(g,{style:[{flexDirection:"row"},r],accessibilityLabel:this.props.accessibilityLabel,testID:this.props.testID,children:t(g,S({},this.panResponder.panHandlers,{style:{flex:1},children:t(g,{style:{borderRadius:y,backgroundColor:f,height:w+2*E},onLayout:e=>{const{width:t}=e.nativeEvent.layout;this.setState({sliderWidth:t-(x?2:0)})},children:e(g,{style:{flex:1,flexDirection:"row",borderColor:d,borderRadius:y,borderWidth:x?b:0,alignItems:"center"},children:[!!T&&t(p.View,{style:[{height:x?w-2*O-2*b:w,backgroundColor:this.getBgColor(),width:T/P.length-((x?O:0)+2*E),transform:[{translateX:this.animatedValue.interpolate({inputRange:[0,1],outputRange:[x?O:0,T-(x?O:0)]})}],borderRadius:y,margin:E},Se.animated]},void 0),$]},void 0)},void 0)}),void 0)},void 0)}}xe.defaultProps={style:{marginHorizontal:20,marginVertical:5,flex:1},textStyle:{flex:1},selectedTextStyle:{fontWeight:"bold"},textContainerStyle:{flexGrow:1,paddingHorizontal:20,marginHorizontal:5},selectedTextContainerStyle:{paddingHorizontal:20},imageStyle:{},options:[],textColor:"#67758B",selectedColor:"#ffffff",fontSize:14,backgroundColor:"#ffffff",borderColor:"#f4f5f9",borderRadius:50,borderWidth:1,hasPadding:!0,valuePadding:1,height:40,bold:!1,buttonMargin:0,buttonColor:"#d22e2e",returnObject:!1,animationDuration:100,disabled:!1,disableValueChangeOnPress:!1,initial:-1,value:1,onPress:null,accessibilityLabel:null,testID:null},xe.propTypes={style:ge.oneOfType([ge.object,ge.array]),textStyle:ge.object,selectedTextStyle:ge.object,textContainerStyle:ge.object,selectedTextContainerStyle:ge.object,imageStyle:ge.object,options:ge.array,textColor:ge.string,selectedColor:ge.string,fontSize:ge.number,backgroundColor:ge.string,borderColor:ge.string,borderRadius:ge.number,borderWidth:ge.number,hasPadding:ge.bool,valuePadding:ge.number,height:ge.number,bold:ge.bool,buttonMargin:ge.number,buttonColor:ge.string,returnObject:ge.bool,animationDuration:ge.number,disabled:ge.bool,disableValueChangeOnPress:ge.bool,initial:ge.number,value:ge.number,onPress:ge.func,accessibilityLabel:ge.string,testID:ge.string};export{$ as Button,E as Checkbox,P as FormControl,T as Heading,I as Input,j as SelectGroup,C as SelectItem,x as Slider,w as Switch,xe as SwitchSelector,O as TextArea}; //# sourceMappingURL=qvt-components.modern.js.map