qvt-components
Version:
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
3 lines (2 loc) • 19.7 kB
JavaScript
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 c,Input as s,Heading as u,Button as l}from"native-base";import f,{Component as p}from"react";import{TouchableOpacity as d,Image as y,Text as b,View as m,Animated as v,I18nManager as h,PanResponder 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)}function O(e,t){return O=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},O(e,t)}var x=function(n){return e(r,S({},n,{children:[t(r.Track,{children:t(r.FilledTrack,{},void 0)},void 0),t(r.Thumb,{},void 0)]}),void 0)},w=function(e){return t(n,S({},e),void 0)},C=function(e){return t(o,S({},e),void 0)},j=function(e){return t(i.Item,S({},e),void 0)},E=function(e){return t(i,S({},e),void 0)},P=function(r){var n=f.useState([]);return e(a.Group,{onChange:n[1],value:n[0],children:[t(a,{value:"one",my:2,children:"Item 1"},void 0),t(a,{value:"two"},void 0)]},void 0)},I=function(e){return t(c,S({},e),void 0)},T=function(e){return t(s,S({},e),void 0)},$=function(e){return t(u,S({},e),void 0)},R=function(e){return t(l,S({colorScheme:"primary",variant:"solid"},e),void 0)};function k(e){var t={exports:{}};return e(t,t.exports),t.exports}var _="function"==typeof Symbol&&Symbol.for,D=_?Symbol.for("react.element"):60103,N=_?Symbol.for("react.portal"):60106,V=_?Symbol.for("react.fragment"):60107,M=_?Symbol.for("react.strict_mode"):60108,A=_?Symbol.for("react.profiler"):60114,L=_?Symbol.for("react.provider"):60109,W=_?Symbol.for("react.context"):60110,z=_?Symbol.for("react.async_mode"):60111,F=_?Symbol.for("react.concurrent_mode"):60111,H=_?Symbol.for("react.forward_ref"):60112,q=_?Symbol.for("react.suspense"):60113,B=_?Symbol.for("react.suspense_list"):60120,U=_?Symbol.for("react.memo"):60115,G=_?Symbol.for("react.lazy"):60116,J=_?Symbol.for("react.block"):60121,Y=_?Symbol.for("react.fundamental"):60117,X=_?Symbol.for("react.responder"):60118,K=_?Symbol.for("react.scope"):60119;function Q(e){if("object"==typeof e&&null!==e){var t=e.$$typeof;switch(t){case D:switch(e=e.type){case z:case F:case V:case A:case M:case q:return e;default:switch(e=e&&e.$$typeof){case W:case H:case G:case U:case L:return e;default:return t}}case N:return t}}}function Z(e){return Q(e)===F}var ee={AsyncMode:z,ConcurrentMode:F,ContextConsumer:W,ContextProvider:L,Element:D,ForwardRef:H,Fragment:V,Lazy:G,Memo:U,Portal:N,Profiler:A,StrictMode:M,Suspense:q,isAsyncMode:function(e){return Z(e)||Q(e)===z},isConcurrentMode:Z,isContextConsumer:function(e){return Q(e)===W},isContextProvider:function(e){return Q(e)===L},isElement:function(e){return"object"==typeof e&&null!==e&&e.$$typeof===D},isForwardRef:function(e){return Q(e)===H},isFragment:function(e){return Q(e)===V},isLazy:function(e){return Q(e)===G},isMemo:function(e){return Q(e)===U},isPortal:function(e){return Q(e)===N},isProfiler:function(e){return Q(e)===A},isStrictMode:function(e){return Q(e)===M},isSuspense:function(e){return Q(e)===q},isValidElementType:function(e){return"string"==typeof e||"function"==typeof e||e===V||e===F||e===A||e===M||e===q||e===B||"object"==typeof e&&null!==e&&(e.$$typeof===G||e.$$typeof===U||e.$$typeof===L||e.$$typeof===W||e.$$typeof===H||e.$$typeof===Y||e.$$typeof===X||e.$$typeof===K||e.$$typeof===J)},typeOf:Q},te=k(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,c=e?Symbol.for("react.provider"):60109,s=e?Symbol.for("react.context"):60110,u=e?Symbol.for("react.async_mode"):60111,l=e?Symbol.for("react.concurrent_mode"):60111,f=e?Symbol.for("react.forward_ref"):60112,p=e?Symbol.for("react.suspense"):60113,d=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,v=e?Symbol.for("react.fundamental"):60117,h=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 d=e.type;switch(d){case u:case l:case o:case a:case i:case p:return d;default:var m=d&&d.$$typeof;switch(m){case s:case f:case b:case y:case c:return m;default:return t}}case n:return t}}}var O=l,x=s,w=c,C=r,j=f,E=o,P=b,I=y,T=n,$=a,R=i,k=p,_=!1;function D(e){return S(e)===l}t.AsyncMode=u,t.ConcurrentMode=O,t.ContextConsumer=x,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)===u},t.isConcurrentMode=D,t.isContextConsumer=function(e){return S(e)===s},t.isContextProvider=function(e){return S(e)===c},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)===p},t.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===o||e===l||e===a||e===i||e===p||e===d||"object"==typeof e&&null!==e&&(e.$$typeof===b||e.$$typeof===y||e.$$typeof===c||e.$$typeof===s||e.$$typeof===f||e.$$typeof===v||e.$$typeof===h||e.$$typeof===g||e.$$typeof===m)},t.typeOf=S}()}),re=k(function(e){e.exports="production"===process.env.NODE_ENV?ee:te}),ne=Object.getOwnPropertySymbols,oe=Object.prototype.hasOwnProperty,ie=Object.prototype.propertyIsEnumerable;function ae(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}var ce=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=ae(e),i=1;i<arguments.length;i++){for(var a in r=Object(arguments[i]))oe.call(r,a)&&(o[a]=r[a]);if(ne){n=ne(r);for(var c=0;c<n.length;c++)ie.call(r,n[c])&&(o[n[c]]=r[n[c]])}}return o},se="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED",ue=function(){};if("production"!==process.env.NODE_ENV){var le=se,fe={},pe=Function.call.bind(Object.prototype.hasOwnProperty);ue=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(pe(e,i)){var a;try{if("function"!=typeof e[i]){var c=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 c.name="Invariant Violation",c}a=e[i](t,i,n,r,null,le)}catch(e){a=e}if(!a||a instanceof Error||ue((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 fe)){fe[a.message]=!0;var s=o?o():"";ue("Failed "+r+" type: "+a.message+(null!=s?s:""))}}}de.resetWarningCache=function(){"production"!==process.env.NODE_ENV&&(fe={})};var ye=de,be=Function.call.bind(Object.prototype.hasOwnProperty),me=function(){};function ve(){return null}function he(){}function ge(){}"production"!==process.env.NODE_ENV&&(me=function(e){var t="Warning: "+e;"undefined"!=typeof console&&console.error(t);try{throw new Error(t)}catch(e){}}),ge.resetWarningCache=he;var Se=k(function(e){e.exports="production"!==process.env.NODE_ENV?function(e,t){var r="function"==typeof Symbol&&Symbol.iterator,n="<<anonymous>>",o={array:s("array"),bool:s("boolean"),func:s("function"),number:s("number"),object:s("object"),string:s("string"),symbol:s("symbol"),any:c(ve),arrayOf:function(e){return c(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 c=t[r];if(!Array.isArray(c))return new a("Invalid "+o+" `"+i+"` of type `"+l(c)+"` supplied to `"+n+"`, expected an array.");for(var s=0;s<c.length;s++){var u=e(c,s,n,o,i+"["+s+"]",se);if(u instanceof Error)return u}return null})},element:c(function(t,r,n,o,i){var c=t[r];return e(c)?null:new a("Invalid "+o+" `"+i+"` of type `"+l(c)+"` supplied to `"+n+"`, expected a single ReactElement.")}),elementType:c(function(e,t,r,n,o){var i=e[t];return re.isValidElementType(i)?null:new a("Invalid "+n+" `"+o+"` of type `"+l(i)+"` supplied to `"+r+"`, expected a single ReactElement type.")}),instanceOf:function(e){return c(function(t,r,o,i,c){return t[r]instanceof e?null:new a("Invalid "+i+" `"+c+"` of type `"+((s=t[r]).constructor&&s.constructor.name?s.constructor.name:n)+"` supplied to `"+o+"`, expected instance of `"+(e.name||n)+"`.");var s})},node:c(function(e,t,r,n,o){return u(e[t])?null:new a("Invalid "+n+" `"+o+"` supplied to `"+r+"`, expected a ReactNode.")}),objectOf:function(e){return c(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 c=t[r],s=l(c);if("object"!==s)return new a("Invalid "+o+" `"+i+"` of type `"+s+"` supplied to `"+n+"`, expected an object.");for(var u in c)if(be(c,u)){var f=e(c,u,n,o,i+"."+u,se);if(f instanceof Error)return f}return null})},oneOf:function(e){if(!Array.isArray(e))return"production"!==process.env.NODE_ENV&&me(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."),ve;function t(t,r,n,o,c){for(var s=t[r],u=0;u<e.length;u++)if(i(s,e[u]))return null;var l=JSON.stringify(e,function(e,t){return"symbol"===f(t)?String(t):t});return new a("Invalid "+o+" `"+c+"` of value `"+String(s)+"` supplied to `"+n+"`, expected one of "+l+".")}return c(t)},oneOfType:function(e){if(!Array.isArray(e))return"production"!==process.env.NODE_ENV&&me("Invalid argument supplied to oneOfType, expected an instance of array."),ve;for(var t=0;t<e.length;t++){var r=e[t];if("function"!=typeof r)return me("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+p(r)+" at index "+t+"."),ve}return c(function(t,r,n,o,i){for(var c=0;c<e.length;c++)if(null==(0,e[c])(t,r,n,o,i,se))return null;return new a("Invalid "+o+" `"+i+"` supplied to `"+n+"`.")})},shape:function(e){return c(function(t,r,n,o,i){var c=t[r],s=l(c);if("object"!==s)return new a("Invalid "+o+" `"+i+"` of type `"+s+"` supplied to `"+n+"`, expected `object`.");for(var u in e){var f=e[u];if(f){var p=f(c,u,n,o,i+"."+u,se);if(p)return p}}return null})},exact:function(e){return c(function(t,r,n,o,i){var c=t[r],s=l(c);if("object"!==s)return new a("Invalid "+o+" `"+i+"` of type `"+s+"` supplied to `"+n+"`, expected `object`.");var u=ce({},t[r],e);for(var f in u){var p=e[f];if(!p)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 d=p(c,f,n,o,i+"."+f,se);if(d)return d}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 c(e){function t(t,r,o,i,c,s,u){if(i=i||n,s=s||o,u!==se){var l=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 l.name="Invariant Violation",l}return null==r[o]?t?new a(null===r[o]?"The "+c+" `"+s+"` is marked as required in `"+i+"`, but its value is `null`.":"The "+c+" `"+s+"` is marked as required in `"+i+"`, but its value is `undefined`."):null:e(r,o,i,c,s)}process;var r=t.bind(null,!1);return r.isRequired=t.bind(null,!0),r}function s(e){return c(function(t,r,n,o,i,c){var s=t[r];return l(s)!==e?new a("Invalid "+o+" `"+i+"` of type `"+f(s)+"` supplied to `"+n+"`, expected `"+e+"`."):null})}function u(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(u);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(!u(o.value))return!1}else for(;!(o=i.next()).done;){var a=o.value;if(a&&!u(a[1]))return!1}return!0;default:return!1}}function l(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=l(e);if("object"===t){if(e instanceof Date)return"date";if(e instanceof RegExp)return"regexp"}return t}function p(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=ye,o.resetWarningCache=ye.resetWarningCache,o.PropTypes=o,o}(re.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:ge,resetWarningCache:he};return r.PropTypes=r,r}()}),Oe={button:{flex:1,flexDirection:"row",justifyContent:"center",alignItems:"center"},animated:{borderWidth:0,position:"absolute"}},xe=/*#__PURE__*/function(r){var n,o;function i(e){var t;(t=r.call(this,e)||this).responderEnd=function(e,r){var n=t.props,o=n.options,i=t.state.selected;if(!n.disabled){var a=t.getSwipeDirection(r);"RIGHT"===a&&i<o.length-1?t.toggleItem(i+1):"LEFT"===a&&i>0&&t.toggleItem(i-1)}},t.shouldSetResponder=function(e,t){return 1===e.nativeEvent.touches.length&&!(Math.abs(t.dx)<5&&Math.abs(t.dy)<5)},t.animate=function(e,r){var n=t.props.animationDuration;t.animatedValue.setValue(r),v.timing(t.animatedValue,{toValue:e,duration:n,useNativeDriver:!0}).start()},t.toggleItem=function(e,r){void 0===r&&(r=!0);var n=t.state.selected,o=t.props,i=o.options,a=o.returnObject,c=o.onPress;i.length<=1||null===e||isNaN(e)||(t.animate(h.isRTL?-e/i.length:e/i.length,h.isRTL?-n/i.length:n/i.length),r&&c?c(a?i[e]:i[e].value):console.log("Call onPress with value: ",i[e].value),t.setState({selected:e}))};var n=e.initial,o=e.options;return t.state={selected:n},t.panResponder=g.create({onStartShouldSetPanResponder:t.shouldSetResponder,onMoveShouldSetPanResponder:t.shouldSetResponder,onPanResponderRelease:t.responderEnd,onPanResponderTerminate:t.responderEnd}),t.animatedValue=new v.Value(n?h.isRTL?-n/o.length:n/o.length:0),t}o=r,(n=i).prototype=Object.create(o.prototype),n.prototype.constructor=n,O(n,o);var a=i.prototype;return a.componentDidUpdate=function(e){var t=this.props,r=t.value;e.value!==r&&this.toggleItem(r,!t.disableValueChangeOnPress)},a.getSwipeDirection=function(e){var t=e.dx,r=e.dy;return Math.abs(e.vx)>.1&&Math.abs(r)<80?t>0?"RIGHT":"LEFT":null},a.getBgColor=function(){var e=this.state.selected,t=this.props;return-1===e?"transparent":t.options[e].activeColor||t.buttonColor},a.render=function(){var r=this,n=this.props,o=n.style,i=n.textStyle,a=n.selectedTextStyle,c=n.textContainerStyle,s=n.selectedTextContainerStyle,u=n.imageStyle,l=n.textColor,f=n.selectedColor,p=n.fontSize,h=n.backgroundColor,g=n.borderColor,O=n.borderRadius,x=n.borderWidth,w=n.hasPadding,C=n.valuePadding,j=n.height,E=n.bold,P=n.disabled,I=n.buttonMargin,T=n.options,$=this.state,R=$.selected,k=$.sliderWidth,_=T.map(function(n,o){var m=R===o;return e(d,{disabled:P,style:[Oe.button,m?s:c],onPress:function(){return r.toggleItem(o)},accessibilityLabel:n.accessibilityLabel,testID:n.testID,children:["function"==typeof n.customIcon?n.customIcon(m):n.customIcon,n.imageIcon&&t(y,{source:n.imageIcon,style:[{height:30,width:30,tintColor:m?f:l},u]},void 0),t(b,{style:[{fontSize:p,fontWeight:E?"bold":"normal",textAlign:"center",color:m?f:l,backgroundColor:"transparent"},m?a:i],numberOfLines:1,children:n.label},void 0)]},o)});return t(m,{style:[{flexDirection:"row"},o],accessibilityLabel:this.props.accessibilityLabel,testID:this.props.testID,children:t(m,S({},this.panResponder.panHandlers,{style:{flex:1},children:t(m,{style:{borderRadius:O,backgroundColor:h,height:j+2*I},onLayout:function(e){r.setState({sliderWidth:e.nativeEvent.layout.width-(w?2:0)})},children:e(m,{style:{flex:1,flexDirection:"row",borderColor:g,borderRadius:O,borderWidth:w?x:0,alignItems:"center"},children:[!!k&&t(v.View,{style:[{height:w?j-2*C-2*x:j,backgroundColor:this.getBgColor(),width:k/T.length-((w?C:0)+2*I),transform:[{translateX:this.animatedValue.interpolate({inputRange:[0,1],outputRange:[w?C:0,k-(w?C:0)]})}],borderRadius:O,margin:I},Oe.animated]},void 0),_]},void 0)},void 0)}),void 0)},void 0)},i}(p);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:Se.oneOfType([Se.object,Se.array]),textStyle:Se.object,selectedTextStyle:Se.object,textContainerStyle:Se.object,selectedTextContainerStyle:Se.object,imageStyle:Se.object,options:Se.array,textColor:Se.string,selectedColor:Se.string,fontSize:Se.number,backgroundColor:Se.string,borderColor:Se.string,borderRadius:Se.number,borderWidth:Se.number,hasPadding:Se.bool,valuePadding:Se.number,height:Se.number,bold:Se.bool,buttonMargin:Se.number,buttonColor:Se.string,returnObject:Se.bool,animationDuration:Se.number,disabled:Se.bool,disableValueChangeOnPress:Se.bool,initial:Se.number,value:Se.number,onPress:Se.func,accessibilityLabel:Se.string,testID:Se.string};export{R as Button,P as Checkbox,I as FormControl,$ as Heading,T as Input,E as SelectGroup,j as SelectItem,x as Slider,C as Switch,xe as SwitchSelector,w as TextArea};
//# sourceMappingURL=qvt-components.esm.js.map