fe-pilot
Version:
scanner in web, phonebook in web, autofill otp in web, share web, TextToSpeech in web, Voice Recognition in web, live location tracking in web, detect my location web, wakelock in web, color picker, WhatsappShare, SnapScanner, NetworkMonitor, View360
1 lines • 3.04 kB
JavaScript
function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}function _defineProperty(a,b,c){return(b=_toPropertyKey(b))in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"==_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!=_typeof(a)||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){var d=c.call(a,b||"default");if("object"!=_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}import React from"react";import{handleSuccess,handleError,handleLoading}from"../services/handlerService";import Wrapper from"../Wrapper/Wrapper";var failureMsgDefault={unSupported:"Your browser does not support the Color Picker fetaure",error:""},isBrowserSupport=function(){return globalThis.EyeDropper},colorPicker=function(){var a=0<arguments.length&&arguments[0]!==void 0?arguments[0]:{},b=a.successCb,c=void 0===b?function(){}:b,d=a.failureCb,e=void 0===d?function(){}:d,f=a.loadingCb,g=void 0===f?function(){}:f,h=a.successMsg,i=void 0===h?"Color picked successfully!!":h,j=a.failureMsg,k=void 0===j?_objectSpread({},failureMsgDefault):j,l=_objectSpread(_objectSpread({},failureMsgDefault),k);(function(){if(isBrowserSupport()){handleLoading({loadingCb:g});var a=new globalThis.EyeDropper;a.open().then(function(a){handleSuccess({msgType:"SUCCESSFUL",msg:i,successCb:c,data:a.sRGBHex})})["catch"](function(a){return handleError({msgType:"ERROR",msg:l.error||(null===a||void 0===a?void 0:a.message)||"Unable to copy color code",failureCb:e})})}else return handleError({msgType:"UN_SUPPORTED_FEATURE",msg:l.unSupported,failureCb:e});return!0})()};function ColorPicker(a){var b=a.children,c=a.successCb,d=a.failureCb,e=a.loadingCb,f=a.successMsg,g=a.failureMsg;return React.Children.map(b||"Copy Color",function(a){return React.cloneElement("string"==typeof a?React.createElement("span",null,a):a,{onClick:function(){return colorPicker({successCb:c,failureCb:d,loadingCb:e,successMsg:f,failureMsg:g})}})})}var WColorPicker=Wrapper(ColorPicker,isBrowserSupport);export{colorPicker,WColorPicker as ColorPicker};export default WColorPicker;