Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@apideck/file-picker

Package Overview
Dependencies
Maintainers
6
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@apideck/file-picker - npm Package Compare versions

Comparing version 0.1.5-0 to 0.1.6

dist/components/Search.d.ts

6

dist/components/FileDetails.d.ts

@@ -1,6 +0,6 @@

/// <reference types="react" />
import { Dispatch, SetStateAction } from 'react';
import { File } from '../types/File';
interface Props {
file: any;
setFile: any;
file: File | null;
setFile: Dispatch<SetStateAction<File | null>>;
onSelect: (file: File) => any;

@@ -7,0 +7,0 @@ }

@@ -24,2 +24,10 @@ import React, { ReactElement } from 'react';

onSelect: (file: File) => any;
/**
* Title shown in the modal
*/
title?: string;
/**
* Subtitle shown in the modal
*/
subTitle?: string;
}

@@ -26,0 +34,0 @@ export declare const EventsContext: React.Context<{

@@ -20,2 +20,10 @@ import { FC } from 'react';

onSelect: (file: File) => any;
/**
* Title shown in the modal
*/
title?: string;
/**
* Subtitle shown in the modal
*/
subTitle?: string;
}

@@ -22,0 +30,0 @@ /**

@@ -1,2 +0,2 @@

"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"),r=e(t),n=require("@headlessui/react"),a=require("react-dom"),o=e(require("swr")),i=require("react-table");function l(e,t,r,n,a,o,i){try{var l=e[o](i),c=l.value}catch(e){return void r(e)}l.done?t(c):Promise.resolve(c).then(n,a)}function c(e){return function(){var t=this,r=arguments;return new Promise((function(n,a){var o=e.apply(t,r);function i(e){l(o,n,a,i,c,"next",e)}function c(e){l(o,n,a,i,c,"throw",e)}i(void 0)}))}}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}).apply(this,arguments)}var u,m=["children","onClose","isOpen","className","style"],d=r.forwardRef((function(e,o){var i=e.children,l=e.onClose,c=e.isOpen,u=e.className,d=void 0===u?"":u,f=e.style,p=void 0===f?{}:f,h=function(e,t){if(null==e)return{};var r,n,a={},o=Object.keys(e);for(n=0;n<o.length;n++)t.indexOf(r=o[n])>=0||(a[r]=e[r]);return a}(e,m),v=t.useState(!1),y=v[0],g=v[1];t.useEffect((function(){g(!0)}),[]);var x=r.createElement(n.Transition,{show:c},r.createElement(n.Transition.Child,{enter:"transition ease-out duration-150",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"transition ease-in duration-150",leaveFrom:"opacity-100",leaveTo:"opacity-0"},r.createElement("div",{className:"fixed inset-0 z-40 flex items-end bg-gray-400 bg-opacity-75 dark:bg-gray-600 sm:items-center sm:justify-center","data-testid":"backdrop",onClick:l},r.createElement(n.Transition.Child,Object.assign({enter:"transition ease-out duration-150",enterFrom:"opacity-0 transform translate-y-1/4 scale-95",enterTo:"opacity-100 scale-100",leave:"transition ease-in duration-150",leaveFrom:"opacity-100 scale-100",leaveTo:"opacity-0 transform translate-y-1/4 scale-95",className:"w-full p-5 overflow-hidden bg-white dark:bg-gray-800 dark-text-gray-400 shadow-lg rounded-t-lg sm:p-6 no-scrollbar sm:rounded-lg sm:m-4 sm:max-w-xl relative "+d,style:s({maxHeight:"90%"},p),ref:o,role:"dialog",onClick:function(e){return e.stopPropagation()}},h),i))));return y?a.createPortal(x,document.body):null})),f=(function(e){var t=function(e){var t=Object.prototype,r=t.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},a=n.iterator||"@@iterator",o=n.asyncIterator||"@@asyncIterator",i=n.toStringTag||"@@toStringTag";function l(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,r){return e[t]=r}}function c(e,t,r,n){var a=Object.create((t&&t.prototype instanceof m?t:m).prototype),o=new N(n||[]);return a._invoke=function(e,t,r){var n="suspendedStart";return function(a,o){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===a)throw o;return{value:void 0,done:!0}}for(r.method=a,r.arg=o;;){var i=r.delegate;if(i){var l=w(i,r);if(l){if(l===u)continue;return l}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=s(e,t,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===u)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(e,r,o),a}function s(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=c;var u={};function m(){}function d(){}function f(){}var p={};l(p,a,(function(){return this}));var h=Object.getPrototypeOf,v=h&&h(h(k([])));v&&v!==t&&r.call(v,a)&&(p=v);var y=f.prototype=m.prototype=Object.create(p);function g(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function x(e,t){var n;this._invoke=function(a,o){function i(){return new t((function(n,i){!function n(a,o,i,l){var c=s(e[a],e,o);if("throw"!==c.type){var u=c.arg,m=u.value;return m&&"object"==typeof m&&r.call(m,"__await")?t.resolve(m.__await).then((function(e){n("next",e,i,l)}),(function(e){n("throw",e,i,l)})):t.resolve(m).then((function(e){u.value=e,i(u)}),(function(e){return n("throw",e,i,l)}))}l(c.arg)}(a,o,n,i)}))}return n=n?n.then(i,i):i()}}function w(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,w(e,t),"throw"===t.method))return u;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return u}var n=s(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,u;var a=n.arg;return a?a.done?(t[e.resultName]=a.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,u):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,u)}function E(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function b(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function N(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(E,this),this.reset(!0)}function k(e){if(e){var t=e[a];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,o=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return o.next=o}}return{next:j}}function j(){return{value:void 0,done:!0}}return d.prototype=f,l(y,"constructor",f),l(f,"constructor",d),d.displayName=l(f,i,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===d||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,f):(e.__proto__=f,l(e,i,"GeneratorFunction")),e.prototype=Object.create(y),e},e.awrap=function(e){return{__await:e}},g(x.prototype),l(x.prototype,o,(function(){return this})),e.AsyncIterator=x,e.async=function(t,r,n,a,o){void 0===o&&(o=Promise);var i=new x(c(t,r,n,a),o);return e.isGeneratorFunction(r)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},g(y),l(y,i,"Generator"),l(y,a,(function(){return this})),l(y,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=k,N.prototype={constructor:N,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(b),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return i.type="throw",i.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],i=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var l=r.call(o,"catchLoc"),c=r.call(o,"finallyLoc");if(l&&c){if(this.prev<o.catchLoc)return n(o.catchLoc,!0);if(this.prev<o.finallyLoc)return n(o.finallyLoc)}else if(l){if(this.prev<o.catchLoc)return n(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return n(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var a=this.tryEntries[n];if(a.tryLoc<=this.prev&&r.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var o=a;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=e,i.arg=t,o?(this.method="next",this.next=o.finallyLoc,u):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),u},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),b(r),u}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var a=n.arg;b(r)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:k(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),u}},e}(e.exports);try{regeneratorRuntime=t}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=t:Function("r","regeneratorRuntime = r")(t)}}(u={exports:{}}),u.exports),p=function(e){var t=e.folders,a=e.handleClick;return r.createElement(n.Transition,{show:!(null==t||!t.length),enter:"transition ease-out duration-200",enterFrom:"transform opacity-60",enterTo:"transform opacity-100",leave:"transition ease-in duration-200",leaveFrom:"transform opacity-100",leaveTo:"transform opacity-0"},r.createElement("div",{className:"flex items-center mb-2 text-sm"},r.createElement("button",{className:"text-gray-600 hover:text-gray-900",onClick:function(){return a()}},r.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"inline-block w-6 h-6 text-yellow-300",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},r.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 19a2 2 0 01-2-2V7a2 2 0 012-2h4l2 2h4a2 2 0 012 2v1M5 19h14a2 2 0 002-2v-5a2 2 0 00-2-2H9a2 2 0 00-2 2v5a2 2 0 01-2 2z"}))),t.map((function(e,o){return r.createElement(n.Transition.Child,{enter:"transition ease-out duration-200",enterFrom:"transform opacity-60 translate-x-1",enterTo:"transform opacity-100",leave:"transition ease-in duration-100",leaveFrom:"transform opacity-100",leaveTo:"transform opacity-0",className:"flex items-center",as:"div"},r.createElement("svg",{className:"flex-shrink-0 w-5 h-5 text-gray-300",fill:"currentColor",viewBox:"0 0 20 20"},r.createElement("path",{fillRule:"evenodd",d:"M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z",clipRule:"evenodd"})),o===t.length-1?r.createElement("span",{className:"font-medium text-gray-900"},e.name):r.createElement("button",{className:"text-gray-600 hover:text-gray-900",onClick:function(){return a(e)}},e.name))}))))},h=function(e,t){if(void 0===t&&(t=2),0===e)return"0 Bytes";var r=t<0?0:t,n=Math.floor(Math.log(e)/Math.log(1024));return parseFloat((e/Math.pow(1024,n)).toFixed(r))+" "+["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"][n]},v=function(e){var t,n,a=e.file,o=e.setFile,i=e.onSelect;return r.createElement("div",{className:"flex flex-col justify-between h-full"},r.createElement("dl",{className:"grid grid-cols-1 gap-x-4 gap-y-6 sm:grid-cols-2"},r.createElement("div",{className:"sm:col-span-1"},r.createElement("dt",{className:"text-sm font-medium text-gray-500"},"Name"),r.createElement("dd",{className:"mt-1 text-sm text-gray-900"},null==a?void 0:a.name)),r.createElement("div",{className:"sm:col-span-1"},r.createElement("dt",{className:"text-sm font-medium text-gray-500"},"Size"),r.createElement("dd",{className:"mt-1 text-sm text-gray-900"},null!=a&&a.size?h(null==a?void 0:a.size):"-")),r.createElement("div",{className:"sm:col-span-1"},r.createElement("dt",{className:"text-sm font-medium text-gray-500"},"Mime type"),r.createElement("dd",{className:"mt-1 text-sm text-gray-900"},null==a?void 0:a.mime_type)),r.createElement("div",{className:"sm:col-span-1"},r.createElement("dt",{className:"text-sm font-medium text-gray-500"},"Downloadable"),r.createElement("dd",{className:"mt-1 text-sm text-gray-900"},null!=a&&a.downloadable?"Yes":"No")),r.createElement("div",{className:"sm:col-span-1"},r.createElement("dt",{className:"text-sm font-medium text-gray-500"},"Created"),r.createElement("dd",{className:"mt-1 text-sm text-gray-900"},r.createElement("div",null,r.createElement("span",{className:"mr-2 text-gray-900"},new Date(null==a?void 0:a.created_at).toLocaleDateString()),r.createElement("span",{className:"text-gray-500 "},new Date(null==a?void 0:a.created_at).toLocaleTimeString())))),r.createElement("div",{className:"sm:col-span-1"},r.createElement("dt",{className:"text-sm font-medium text-gray-500"},"Updated"),r.createElement("dd",{className:"mt-1 text-sm text-gray-900"},r.createElement("div",null,r.createElement("span",{className:"mr-2 text-gray-900"},new Date(null==a?void 0:a.updated_at).toLocaleDateString()),r.createElement("span",{className:"text-gray-500 "},new Date(null==a?void 0:a.updated_at).toLocaleTimeString())))),r.createElement("div",{className:"sm:col-span-1"},r.createElement("dt",{className:"text-sm font-medium text-gray-500"},"Owner"),r.createElement("dd",{className:"mt-1 text-sm text-gray-900"},null==a||null==(t=a.owner)?void 0:t.name)),r.createElement("div",{className:"sm:col-span-1"},r.createElement("dt",{className:"text-sm font-medium text-gray-500"},"Email"),r.createElement("dd",{className:"mt-1 text-sm text-gray-900"},null==a||null==(n=a.owner)?void 0:n.email))),r.createElement("div",{className:"flex justify-between pt-6"},r.createElement("button",{type:"button",className:"items-center w-full px-3 py-2 mr-3 text-sm font-medium leading-4 text-gray-700 bg-white border border-gray-300 rounded-md shadow-sm hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500",onClick:function(){return o(null)}},"Close"),r.createElement("button",{type:"button",className:"items-center w-full px-3 py-2 ml-3 text-sm font-medium leading-4 text-white bg-indigo-600 border border-transparent rounded-md shadow-sm hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500",onClick:function(){return i(a)}},"Select File")))},y=[{Header:"Name"},{Header:"Size"},{Header:"Updated"}],g=function(){var e=Array.from(Array(8).keys());return r.createElement("table",{className:"min-w-full divide-y divide-gray-200"},r.createElement("thead",null,r.createElement("tr",null,y.map((function(e,t){return r.createElement("th",{key:"column-"+t,className:"py-3 space-x-6 text-xs font-medium tracking-wide text-left text-gray-500 uppercase"},e.Header)})))),r.createElement("tbody",{className:"bg-white divide-y divide-gray-200"},e.map((function(e,t){return r.createElement(x,{key:t})}))))},x=function(){return r.createElement("tr",null,y.map((function(e,t){return r.createElement("td",{className:"py-4 space-x-6 text-sm font-medium truncate whitespace-nowrap",key:"cell-"+t,style:{maxWidth:200}},r.createElement("span",{className:"px-16 py-0 bg-gray-200 rounded-sm animate-pulse"}))})))},w=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],E=function(e){var t=e.data,a=void 0===t?[]:t,o=e.isLoadingMore,l=e.handleSelect,c=r.useMemo((function(){return[{Header:"Name",accessor:"name",Cell:function(e){return"folder"===e.row.original.type?r.createElement("div",{className:"flex items-center"},r.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6 inline-block mr-1 text-yellow-300",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},r.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z"})),r.createElement("span",{className:"truncate"},e.value)):r.createElement("div",{className:"flex items-center truncate"},r.createElement("svg",{viewBox:"0 0 24 24",className:"h-6 w-6 inline-block mr-1 text-gray-500"},r.createElement("path",{d:"M17 6v12c0 .52-.2 1-1 1H4c-.7 0-1-.33-1-1V2c0-.55.42-1 1-1h8l5 5zM14 8h-3.13c-.51 0-.87-.34-.87-.87V4",stroke:"currentColor",fill:"none",fillRule:"evenodd",strokeLinejoin:"round"})),r.createElement("span",{className:"truncate"},e.value))}},{Header:"Size",accessor:"size",Cell:function(e){var t=e.value;return r.createElement("div",null,t?h(t):null)}},{Header:"Updated",accessor:"updated_at",Cell:function(e){var t=e.value,n=new Date(t);return r.createElement("span",{className:"text-gray-900"},w[n.getMonth()]+" "+n.getDay()+", "+new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}))}}]}),[]),s=i.useTable({columns:c,data:a},i.useSortBy),u=s.getTableBodyProps,m=s.rows,d=s.prepareRow;return r.createElement("div",{className:"overflow-auto"},r.createElement("table",{className:"min-w-full divide-y divide-gray-200"},r.createElement("thead",{className:""},s.headerGroups.map((function(e,t){return r.createElement("tr",Object.assign({},e.getHeaderGroupProps(),{key:"headerGroup"+t}),e.headers.map((function(e,t){return r.createElement("th",Object.assign({key:"column-"+t,className:"py-3 pr-2 space-x-6 text-xs tracking-wide text-left text-gray-500 uppercase font-medium"},e.getHeaderProps(e.getSortByToggleProps())),e.render("Header"),r.createElement("span",null,e.isSorted?r.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",className:"inline-block w-4 h-4 ml-2 text-gray-500"},r.createElement("path",e.isSortedDesc?{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"}:{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15l7-7 7 7"})):""))})))}))),r.createElement("tbody",Object.assign({},u(),{className:"bg-white divide-y divide-gray-200"}),m.map((function(e,t){return d(e),r.createElement(n.Transition,Object.assign({show:!0,enter:"transition ease-out duration-300",enterFrom:"transform opacity-40",enterTo:"transform opacity-100",leave:"transition ease-in duration-300",leaveFrom:"transform opacity-100",leaveTo:"transform opacity-0",as:"tr"},e.getRowProps(),{key:"row-"+t,className:"hover:bg-gray-50 cursor-pointer",onClick:function(){return l(e.original)}}),e.cells.map((function(e,t){return r.createElement("td",Object.assign({className:"max-w-2xs py-3 space-x-6 text-xs text-gray-900 truncate whitespace-nowrap"},e.getCellProps(),{key:"cell-"+t}),e.render("Cell"))})))})))),o?r.createElement("table",{className:"min-w-full divide-y divide-gray-200"},Array.from(Array(16).keys()).map((function(e){return r.createElement(x,{key:e})}))):"")},b=function(e){return r.createElement(n.Transition,{show:e.open,as:t.Fragment},r.createElement("div",{className:"absolute bottom-0 left-0 right-0 rounded-t-2xl",style:{width:"calc(100% - 3rem)",left:"1.5rem"}},r.createElement(n.Transition.Child,{as:t.Fragment,enter:"transform transition ease-in-out duration-300",enterFrom:"translate-y-full",enterTo:"translate-y-0",leave:"transform transition ease-in-out duration-300",leaveFrom:"translate-y-0",leaveTo:"translate-y-full"},r.createElement("div",{className:"relative w-full rounded-t-2xl"},r.createElement("div",{className:"flex flex-col h-full py-6 overflow-y-auto bg-white border border-gray-200 rounded-t-lg shadow-sm"},r.createElement("div",{className:"relative flex-1 px-4 sm:px-6"},e.children))))))},N=function(e){var n=e.appId,a=e.consumerId,i=e.jwt,l=e.serviceId,s=e.onSelect,u=t.useState("root"),m=u[0],d=u[1],h=t.useState([]),y=h[0],x=h[1],w=t.useState(null),N=w[0],k=w[1],j=o("https://unify.apideck.com/file-storage/files?filter[folderId]="+m,function(){var e=c(f.mark((function e(t){var r;return f.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,fetch(t,{headers:{"Content-Type":"application/json","x-apideck-auth-type":"JWT","x-apideck-app-id":n,"x-apideck-consumer-id":a,"x-apideck-service-id":l,Authorization:"Bearer "+i}});case 2:return r=e.sent,e.next=5,r.json();case 5:return e.abrupt("return",e.sent);case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),L=j.data,T=j.error,C=!L&&!T,S=T||(null==L?void 0:L.error);return r.createElement(t.Fragment,null,r.createElement(p,{folders:y,handleClick:function(e){if(e){d(e.id);var t=y.indexOf(e),r=[].concat(y.slice(0,t+1));x(r)}else d("root"),x([])}}),C?r.createElement(g,null):r.createElement(E,{data:null==L?void 0:L.data,handleSelect:function(e){"folder"===e.type&&(d(e.id),x([].concat(y,[e]))),"file"===e.type&&k(e)}}),C?null:r.createElement(b,{open:!!N},r.createElement(v,{file:N,setFile:k,onSelect:s})),!C&&T&&r.createElement("p",{className:"text-red-600"},(null==S?void 0:S.message)||S))},k=function(e){var t=e.className;return r.createElement("svg",{className:"text-blue-600 animate-spin "+(void 0===t?"w-8 h-8":t),xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24"},r.createElement("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),r.createElement("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"}))},j=function(e){return!!e.configured&&("oauth2"===e.auth_type?!(null==e||!e.revoke_url):function(e){var t=e.form_fields;if(0===(null==t?void 0:t.length))return!0;var r=t.filter((function(e){return e.required}));return 0===(null==r?void 0:r.length)||r.every((function(e){return""!==e.value}))}(e))},L=function(e){var t=e.jwt,a=e.connections,o=e.connection,i=e.setConnection,l=e.isLoading,s=function(){var e=c(f.mark((function e(t){return f.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:j(t)||u(),i(t);case 2:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),u=function(){window.location.href="https://vault.apideck.com/integrations/crm/"+(null==o?void 0:o.service_id)+"/enable?jwt="+t},m=function(e){return e.enabled?j(e)?"bg-primary-500":"bg-yellow-400":"bg-gray-300"};return r.createElement("div",{className:"relative inline-block"},r.createElement(n.Menu,null,(function(e){var t=e.open;return r.createElement(r.Fragment,null,r.createElement(n.Menu.Button,{className:"flex items-center justify-between w-full px-4 py-2 text-sm font-medium text-blue-800 bg-blue-100 border border-blue-200 rounded-md group hover:bg-cool-gray-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-cool-gray-100 focus:ring-blue-600",style:{minWidth:240}},r.createElement("div",null,!l&&(null==o?void 0:o.icon)&&r.createElement("img",{className:"inline-block w-6 h-6 mr-2 rounded-full "+(l?"animate-spin opacity-20":""),src:!l&&null!=o&&o.icon?null==o?void 0:o.icon:"/img/logo.png",alt:""}),l&&r.createElement(k,{className:"w-6 h-6"}),!l&&r.createElement("span",null,(null==o?void 0:o.name)||"No integrations")),r.createElement("svg",{className:"w-5 h-5 ml-2 -mr-1",viewBox:"0 0 20 20",fill:"currentColor"},r.createElement("path",{fillRule:"evenodd",d:"M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z",clipRule:"evenodd"}))),r.createElement(n.Transition,{show:t,enter:"transition ease-out duration-100",enterFrom:"transform opacity-0 scale-95",enterTo:"transform opacity-100 scale-100",leave:"transition ease-in duration-75",leaveFrom:"transform opacity-100 scale-100",leaveTo:"transform opacity-0 scale-95",className:"min-w-sm"},r.createElement(n.Menu.Items,{static:!0,className:"absolute right-0 z-10 w-full mt-2 origin-top-right bg-white border divide-y rounded-md outline-none border-cool-gray-200 divide-cool-gray-100"},r.createElement("div",{className:"py-1"},null==a?void 0:a.map((function(e,t){return r.createElement(n.Menu.Item,{key:t},(function(t){return r.createElement("div",{onClick:function(){return s(e)},className:(t.active?"bg-gray-100 text-gray-900":"text-gray-600")+" flex items-center justify-between min-w-0 mx-2 cursor-pointer rounded-md py-0.5 overflow-hidden "+(e.enabled?"":"opacity-60")},r.createElement("img",{className:"flex-shrink-0 w-6 h-6 m-2 rounded-full",src:e.icon,alt:""}),r.createElement("span",{className:"flex-1 min-w-0"},r.createElement("span",{className:"text-sm font-medium text-gray-900 truncate"},e.name)),r.createElement("span",{className:"inline-block w-2.5 h-2.5 mr-2 rounded-full ring-2 ring-white "+m(e)}))}))})),r.createElement(n.Menu.Item,null,(function(e){return r.createElement("div",{onClick:function(){return u()},className:(e.active?"bg-gray-100 text-gray-900":"text-gray-600")+" flex items-center justify-between min-w-0 mx-2 cursor-pointer rounded-md py-0.5 overflow-hidden"},r.createElement("svg",{className:"flex-shrink-0 w-6 h-6 m-2",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},r.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6v6m0 0v6m0-6h6m-6 0H6"})),r.createElement("span",{className:"flex-1 min-w-0"},r.createElement("span",{className:"text-sm font-medium text-gray-900 truncate"},"Add integration")))}))))))})))},T=function(e){var n,a=e.appId,i=e.consumerId,l=e.jwt,s=e.onSelect,u=t.useState(),m=u[0],d=u[1],p=o("https://unify.apideck.com/vault/connections",function(){var e=c(f.mark((function e(t){var r;return f.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,fetch(t,{headers:{"Content-Type":"application/json","x-apideck-consumer-id":"test-consumer-ckgrs95l3y4er0b99qa37buj2","x-apideck-app-id":"cfaZrORgaH2PMQpIcjTpfhERIpIEUJHev09ucjTp","x-apideck-auth-type":"JWT",Authorization:"Bearer "+l}});case 2:return r=e.sent,e.next=5,r.json();case 5:return e.abrupt("return",e.sent);case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),h=p.data,v=p.error,y=!h&&!v,g=(null==h?void 0:h.error)||v,x=null==h||null==(n=h.data)?void 0:n.filter((function(e){return"callable"===e.state&&"file-storage"===e.unified_api}));return t.useEffect((function(){!m&&null!=x&&x.length&&d(x[0])}),[d,x]),r.createElement("div",{className:"-m-6 bg-white sm:rounded-lg h-modal"},r.createElement("div",{className:"flex items-center justify-between px-4 py-5 sm:px-6"},r.createElement("div",null,r.createElement("h3",{className:"text-lg font-medium leading-6 text-gray-900"},"Apideck Filepicker"),r.createElement("p",{className:"max-w-2xl mt-1 text-sm text-gray-500"},g?r.createElement("span",{className:"mb-2 text-red-600"},g):r.createElement("span",{className:"text-gray-700 dark:text-gray-400"},m?"Pick a file":"Select connector"))),r.createElement(L,{jwt:l,connections:x,connection:m,setConnection:d,isLoading:y})),r.createElement("div",{className:"px-4 py-5 overflow-y-auto border-t border-gray-200 sm:px-6",style:{maxHeight:"80%"}},m?r.createElement(N,{appId:a,consumerId:i,serviceId:m.service_id,jwt:l,onSelect:s}):r.createElement("div",{className:"flex items-center justify-center border-4 border-gray-200 border-dashed rounded-lg h-96"},null!=x&&x.length||y?null:r.createElement("div",{className:"text-center"},r.createElement("a",{href:"https://vault.apideck.com/session/"+l,target:"_blank",rel:"noreferrer",className:"text-indigo-600 hover:text-indigo-900"},"Go to vault")," ","to add file storage connectors"))))};exports.FilePicker=t.forwardRef((function(e,n){var a=e.appId,o=e.consumerId,i=e.jwt,l=e.trigger,c=e.onSelect,s=t.useState(!1),u=s[0],m=s[1];return r.createElement(t.Fragment,null,r.cloneElement(l,{onClick:function(){return m(!0)},ref:n}),r.createElement(d,{isOpen:u,onClose:function(){return m(!1)}},r.createElement(T,{appId:a,consumerId:o,jwt:i,onSelect:function(e){c(e),m(!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"),r=e(t),n=require("@headlessui/react"),a=require("react-dom"),o=e(require("swr")),l=require("react-waypoint"),i=require("react-table");function c(e,t,r,n,a,o,l){try{var i=e[o](l),c=i.value}catch(e){return void r(e)}i.done?t(c):Promise.resolve(c).then(n,a)}function s(e){return function(){var t=this,r=arguments;return new Promise((function(n,a){var o=e.apply(t,r);function l(e){c(o,n,a,l,i,"next",e)}function i(e){c(o,n,a,l,i,"throw",e)}l(void 0)}))}}function u(){return(u=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}).apply(this,arguments)}var m,d=["children","onClose","isOpen","className","style"],f=r.forwardRef((function(e,o){var l=e.children,i=e.onClose,c=e.isOpen,s=e.className,m=void 0===s?"":s,f=e.style,p=void 0===f?{}:f,h=function(e,t){if(null==e)return{};var r,n,a={},o=Object.keys(e);for(n=0;n<o.length;n++)t.indexOf(r=o[n])>=0||(a[r]=e[r]);return a}(e,d),v=t.useState(!1),g=v[0],y=v[1];t.useEffect((function(){y(!0)}),[]);var x=r.createElement(n.Transition,{show:c},r.createElement(n.Transition.Child,{enter:"transition ease-out duration-150",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"transition ease-in duration-150",leaveFrom:"opacity-100",leaveTo:"opacity-0"},r.createElement("div",{className:"fixed inset-0 z-40 flex items-end bg-gray-400 bg-opacity-75 dark:bg-gray-600 sm:items-center sm:justify-center","data-testid":"backdrop",onClick:i},r.createElement(n.Transition.Child,Object.assign({enter:"transition ease-out duration-150",enterFrom:"opacity-0 transform translate-y-1/4 scale-95",enterTo:"opacity-100 scale-100",leave:"transition ease-in duration-150",leaveFrom:"opacity-100 scale-100",leaveTo:"opacity-0 transform translate-y-1/4 scale-95",className:"w-full p-5 overflow-hidden bg-white dark:bg-gray-800 dark-text-gray-400 shadow-lg rounded-t-lg sm:p-6 no-scrollbar sm:rounded-lg sm:m-4 sm:max-w-xl relative "+m,style:u({maxHeight:"90%"},p),ref:o,role:"dialog",onClick:function(e){return e.stopPropagation()}},h),l))));return g?a.createPortal(x,document.body):null})),p=(function(e){var t=function(e){var t=Object.prototype,r=t.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},a=n.iterator||"@@iterator",o=n.asyncIterator||"@@asyncIterator",l=n.toStringTag||"@@toStringTag";function i(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{i({},"")}catch(e){i=function(e,t,r){return e[t]=r}}function c(e,t,r,n){var a=Object.create((t&&t.prototype instanceof m?t:m).prototype),o=new N(n||[]);return a._invoke=function(e,t,r){var n="suspendedStart";return function(a,o){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===a)throw o;return{value:void 0,done:!0}}for(r.method=a,r.arg=o;;){var l=r.delegate;if(l){var i=w(l,r);if(i){if(i===u)continue;return i}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=s(e,t,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===u)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(e,r,o),a}function s(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=c;var u={};function m(){}function d(){}function f(){}var p={};i(p,a,(function(){return this}));var h=Object.getPrototypeOf,v=h&&h(h(k([])));v&&v!==t&&r.call(v,a)&&(p=v);var g=f.prototype=m.prototype=Object.create(p);function y(e){["next","throw","return"].forEach((function(t){i(e,t,(function(e){return this._invoke(t,e)}))}))}function x(e,t){var n;this._invoke=function(a,o){function l(){return new t((function(n,l){!function n(a,o,l,i){var c=s(e[a],e,o);if("throw"!==c.type){var u=c.arg,m=u.value;return m&&"object"==typeof m&&r.call(m,"__await")?t.resolve(m.__await).then((function(e){n("next",e,l,i)}),(function(e){n("throw",e,l,i)})):t.resolve(m).then((function(e){u.value=e,l(u)}),(function(e){return n("throw",e,l,i)}))}i(c.arg)}(a,o,n,l)}))}return n=n?n.then(l,l):l()}}function w(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,w(e,t),"throw"===t.method))return u;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return u}var n=s(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,u;var a=n.arg;return a?a.done?(t[e.resultName]=a.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,u):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,u)}function E(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function b(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function N(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(E,this),this.reset(!0)}function k(e){if(e){var t=e[a];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,o=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return o.next=o}}return{next:S}}function S(){return{value:void 0,done:!0}}return d.prototype=f,i(g,"constructor",f),i(f,"constructor",d),d.displayName=i(f,l,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===d||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,f):(e.__proto__=f,i(e,l,"GeneratorFunction")),e.prototype=Object.create(g),e},e.awrap=function(e){return{__await:e}},y(x.prototype),i(x.prototype,o,(function(){return this})),e.AsyncIterator=x,e.async=function(t,r,n,a,o){void 0===o&&(o=Promise);var l=new x(c(t,r,n,a),o);return e.isGeneratorFunction(r)?l:l.next().then((function(e){return e.done?e.value:l.next()}))},y(g),i(g,l,"Generator"),i(g,a,(function(){return this})),i(g,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=k,N.prototype={constructor:N,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(b),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return l.type="throw",l.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],l=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var i=r.call(o,"catchLoc"),c=r.call(o,"finallyLoc");if(i&&c){if(this.prev<o.catchLoc)return n(o.catchLoc,!0);if(this.prev<o.finallyLoc)return n(o.finallyLoc)}else if(i){if(this.prev<o.catchLoc)return n(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return n(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var a=this.tryEntries[n];if(a.tryLoc<=this.prev&&r.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var o=a;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var l=o?o.completion:{};return l.type=e,l.arg=t,o?(this.method="next",this.next=o.finallyLoc,u):this.complete(l)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),u},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),b(r),u}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var a=n.arg;b(r)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:k(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),u}},e}(e.exports);try{regeneratorRuntime=t}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=t:Function("r","regeneratorRuntime = r")(t)}}(m={exports:{}}),m.exports),h="undefined"==typeof window||"Deno"in window?t.useEffect:t.useLayoutEffect,v={}[0],g=function(e){return e===v},y=function(e){return"function"==typeof e},x=new WeakMap,w=0;function E(e){if(y(e))try{e=e()}catch(t){e=""}var t;return Array.isArray(e)?(t=e,e=function(e){if(!e.length)return"";for(var t="arg",r=0;r<e.length;++r){var n=e[r],a=v;null===n||"object"!=typeof n&&!y(n)?a=JSON.stringify(n):x.has(n)?a=x.get(n):(a=w,x.set(n,w++)),t+="$"+a}return t}(e)):t=[e=String(e||"")],[e,t,e?"$err$"+e:"",e?"$req$"+e:""]}function b(e){return y(e[1])?[e[0],e[1],e[2]||{}]:[e[0],null,(null===e[1]?e[2]:e[1])||{}]}var N=function(e,t){return function(){for(var r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];var a=b(r),o=a[0],l=a[1],i=a[2];return i.use=(i.use||[]).concat(t),e(o,l,i)}}(o,(function(e){return function(r,n,a){var o=a.cache,l=a.initialSize,i=void 0===l?1:l,c=a.revalidateAll,s=void 0!==c&&c,u=a.persistSize,m=void 0!==u&&u,d=null;try{d=function(e){return E(e?e(0,null):null)[0]}(r)}catch(e){}var f=t.useState({})[1],p=null;d&&(p="$ctx$"+d);var x=null;d&&(x="$len$"+d);var w=t.useRef(!1),b=t.useCallback((function(){var e=o.get(x);return g(e)?i:e}),[x,i]),N=t.useRef(b());h((function(){w.current?d&&o.set(x,m?N.current:i):w.current=!0}),[d]);var k=t.useRef(),S=e(d?"$inf$"+d:null,(function(){return function(e,t,r,n){return new(r||(r=Promise))((function(e,t){function a(e){try{l(n.next(e))}catch(e){t(e)}}function o(e){try{l(n.throw(e))}catch(e){t(e)}}function l(t){var n;t.done?e(t.value):(n=t.value,n instanceof r?n:new r((function(e){e(n)}))).then(a,o)}l((n=n.apply(void 0,[])).next())}))}(0,0,void 0,(function(){var e,t,l,i,c,u,m,d,f,h,v,y;return function(e,t){var r,n,a,o,l={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function i(o){return function(i){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;l;)try{if(r=1,n&&(a=2&o[0]?n.return:o[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,o[1])).done)return a;switch(n=0,a&&(o=[2&o[0],a.value]),o[0]){case 0:case 1:a=o;break;case 4:return l.label++,{value:o[1],done:!1};case 5:l.label++,n=o[1],o=[0];continue;case 7:o=l.ops.pop(),l.trys.pop();continue;default:if(!((a=(a=l.trys).length>0&&a[a.length-1])||6!==o[0]&&2!==o[0])){l=0;continue}if(3===o[0]&&(!a||o[1]>a[0]&&o[1]<a[3])){l.label=o[1];break}if(6===o[0]&&l.label<a[1]){l.label=a[1],a=o;break}if(a&&l.label<a[2]){l.label=a[2],l.ops.push(o);break}a[2]&&l.ops.pop(),l.trys.pop();continue}o=t.call(e,l)}catch(e){o=[6,e],n=0}finally{r=a=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,i])}}}(this,(function(x){switch(x.label){case 0:e=o.get(p)||[],t=e[0],l=e[1],i=[],c=b(),u=null,m=0,x.label=1;case 1:return m<c?(d=E(r?r(m,u):null),h=d[1],(f=d[0])?(v=o.get(f),y=s||t||g(v)||!m&&!g(k.current)||l&&!g(l[m])&&!a.compare(l[m],v),n&&y?[4,n.apply(void 0,h)]:[3,3]):[3,5]):[3,5];case 2:v=x.sent(),o.set(f,v),x.label=3;case 3:i.push(v),u=v,x.label=4;case 4:return++m,[3,1];case 5:return o.delete(p),[2,i]}}))}))}),a);h((function(){k.current=S.data}),[S.data]);var j=t.useCallback((function(e,t){if(void 0===t&&(t=!0),p)return t&&!g(e)?o.set(p,[!1,k.current]):t&&o.set(p,[!0]),S.mutate(e,t)}),[p]),L=t.useCallback((function(e){var t;if(x&&(y(e)?t=e(b()):"number"==typeof e&&(t=e),"number"==typeof t))return o.set(x,t),N.current=t,f({}),j(function(e){for(var t=[],n=null,a=0;a<e;++a){var l=E(r?r(a,n):null)[0],i=l?o.get(l):v;if(g(i))return k.current;t.push(i),n=i}return t}(t))}),[x,b,j]);return{size:b(),setSize:L,mutate:j,get error(){return S.error},get data(){return S.data},get isValidating(){return S.isValidating}}}})),k=function(e){var t=e.folders,a=e.handleClick;return r.createElement(n.Transition,{show:!(null==t||!t.length),enter:"transition ease-out duration-200",enterFrom:"transform opacity-60",enterTo:"transform opacity-100",leave:"transition ease-in duration-200",leaveFrom:"transform opacity-100",leaveTo:"transform opacity-0"},r.createElement("div",{className:"flex items-center text-sm"},r.createElement("button",{className:"text-gray-600 hover:text-gray-900",onClick:function(){return a()}},r.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"inline-block w-5 h-5 text-yellow-300",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},r.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 19a2 2 0 01-2-2V7a2 2 0 012-2h4l2 2h4a2 2 0 012 2v1M5 19h14a2 2 0 002-2v-5a2 2 0 00-2-2H9a2 2 0 00-2 2v5a2 2 0 01-2 2z"}))),t.map((function(e,o){return r.createElement(n.Transition.Child,{enter:"transition ease-out duration-200",enterFrom:"transform opacity-60 translate-x-1",enterTo:"transform opacity-100",leave:"transition ease-in duration-100",leaveFrom:"transform opacity-100",leaveTo:"transform opacity-0",className:"flex items-center",as:"div",key:e.id},r.createElement("svg",{className:"flex-shrink-0 w-5 h-5 text-gray-300",fill:"currentColor",viewBox:"0 0 20 20"},r.createElement("path",{fillRule:"evenodd",d:"M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z",clipRule:"evenodd"})),o===t.length-1?r.createElement("span",{className:"font-medium text-gray-900"},e.name):r.createElement("button",{className:"text-gray-600 hover:text-gray-900",onClick:function(){return a(e)}},e.name))}))))},S=function(e,t){if(void 0===t&&(t=2),0===e)return"0 Bytes";var r=t<0?0:t,n=Math.floor(Math.log(e)/Math.log(1024));return parseFloat((e/Math.pow(1024,n)).toFixed(r))+" "+["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"][n]},j=function(e){var t,n,a=e.file,o=e.setFile,l=e.onSelect;return a?r.createElement("div",{className:"flex flex-col justify-between h-full"},r.createElement("dl",{className:"grid grid-cols-2 gap-x-4 gap-y-6"},r.createElement("div",{className:"col-span-1"},r.createElement("dt",{className:"text-sm font-medium text-gray-500"},"Name"),r.createElement("dd",{className:"mt-1 text-sm text-gray-900"},null==a?void 0:a.name)),r.createElement("div",{className:"col-span-1"},r.createElement("dt",{className:"text-sm font-medium text-gray-500"},"Size"),r.createElement("dd",{className:"mt-1 text-sm text-gray-900"},null!=a&&a.size?S(null==a?void 0:a.size):"-")),r.createElement("div",{className:"col-span-1"},r.createElement("dt",{className:"text-sm font-medium text-gray-500"},"Mime type"),r.createElement("dd",{className:"mt-1 text-sm text-gray-900"},null==a?void 0:a.mime_type)),r.createElement("div",{className:"col-span-1"},r.createElement("dt",{className:"text-sm font-medium text-gray-500"},"Downloadable"),r.createElement("dd",{className:"mt-1 text-sm text-gray-900"},null!=a&&a.downloadable?"Yes":"No")),r.createElement("div",{className:"col-span-1"},r.createElement("dt",{className:"text-sm font-medium text-gray-500"},"Created"),r.createElement("dd",{className:"mt-1 text-sm text-gray-900"},r.createElement("div",null,r.createElement("span",{className:"mr-2 text-gray-900"},(null==a?void 0:a.created_at)&&new Date(a.created_at).toLocaleDateString()),r.createElement("span",{className:"text-gray-500 "},(null==a?void 0:a.created_at)&&new Date(a.created_at).toLocaleTimeString())))),r.createElement("div",{className:"col-span-1"},r.createElement("dt",{className:"text-sm font-medium text-gray-500"},"Updated"),r.createElement("dd",{className:"mt-1 text-sm text-gray-900"},r.createElement("div",null,r.createElement("span",{className:"mr-2 text-gray-900"},(null==a?void 0:a.updated_at)&&new Date(a.updated_at).toLocaleDateString()),r.createElement("span",{className:"text-gray-500 "},(null==a?void 0:a.updated_at)&&new Date(a.updated_at).toLocaleTimeString())))),r.createElement("div",{className:"col-span-1"},r.createElement("dt",{className:"text-sm font-medium text-gray-500"},"Owner"),r.createElement("dd",{className:"mt-1 text-sm text-gray-900"},null==a||null==(t=a.owner)?void 0:t.name)),r.createElement("div",{className:"col-span-1"},r.createElement("dt",{className:"text-sm font-medium text-gray-500"},"Email"),r.createElement("dd",{className:"mt-1 text-sm text-gray-900"},null==a||null==(n=a.owner)?void 0:n.email))),r.createElement("div",{className:"flex justify-between pt-6"},r.createElement("button",{type:"button",className:"items-center w-full px-3 py-2 mr-2 text-sm font-medium leading-4 text-gray-700 bg-white border border-gray-300 rounded-md shadow-sm sm:mr-3 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500",onClick:function(){return o(null)}},"Close"),r.createElement("button",{type:"button",className:"items-center w-full px-3 py-2 ml-2 text-sm font-medium leading-4 text-white bg-indigo-600 border border-transparent rounded-md shadow-sm sm:ml-3 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500",onClick:function(){return l(a)}},"Select file"))):r.createElement("p",{className:"p-4 text-center"},"No file found")},L=[{Header:"Name"},{Header:"Size"},{Header:"Updated"}],T=function(){var e=Array.from(Array(8).keys());return r.createElement("table",{className:"min-w-full divide-y divide-gray-200"},r.createElement("thead",null,r.createElement("tr",null,L.map((function(e,t){return r.createElement("th",{key:"column-"+t,className:"py-3 space-x-6 text-xs font-medium tracking-wide text-left text-gray-500 uppercase"},e.Header)})))),r.createElement("tbody",{className:"bg-white divide-y divide-gray-200"},e.map((function(e,t){return r.createElement(C,{key:t})}))))},C=function(){return r.createElement("tr",null,L.map((function(e,t){return r.createElement("td",{className:"py-4 space-x-6 text-sm font-medium truncate whitespace-nowrap",key:"cell-"+t,style:{maxWidth:100}},r.createElement("span",{className:"px-16 py-0 bg-gray-200 rounded-sm animate-pulse"}))})))},O=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],M=function(e){var t=e.data,a=void 0===t?[]:t,o=e.isLoadingMore,l=e.handleSelect,c=r.useMemo((function(){return[{Header:"Name",accessor:"name",Cell:function(e){return"folder"===e.row.original.type?r.createElement("div",{className:"flex items-center"},r.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"inline-block w-6 h-6 mr-1 text-yellow-300",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},r.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z"})),r.createElement("span",{className:"truncate"},e.value)):r.createElement("div",{className:"flex items-center truncate"},r.createElement("svg",{viewBox:"0 0 24 24",className:"inline-block w-6 h-6 mr-1 text-gray-500"},r.createElement("path",{d:"M17 6v12c0 .52-.2 1-1 1H4c-.7 0-1-.33-1-1V2c0-.55.42-1 1-1h8l5 5zM14 8h-3.13c-.51 0-.87-.34-.87-.87V4",stroke:"currentColor",fill:"none",fillRule:"evenodd",strokeLinejoin:"round"})),r.createElement("span",{className:"truncate"},e.value))}},{Header:"Size",accessor:"size",Cell:function(e){var t=e.value;return r.createElement("div",null,t?S(t):null)}},{Header:"Updated",accessor:"updated_at",Cell:function(e){var t=e.value;if(!t)return r.createElement("span",{className:"text-gray-900"},"-");var n=new Date(t);return r.createElement("span",{className:"text-gray-900 "},O[n.getMonth()]+" "+n.getDay()+", "+new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}))}}]}),[]),s=i.useTable({columns:c,data:a},i.useSortBy),u=s.getTableBodyProps,m=s.rows,d=s.prepareRow;return r.createElement("div",{className:"overflow-auto"},r.createElement("table",{className:"min-w-full divide-y divide-gray-200"},r.createElement("thead",{className:""},s.headerGroups.map((function(e,t){return r.createElement("tr",Object.assign({},e.getHeaderGroupProps(),{key:"headerGroup"+t}),e.headers.map((function(e,t){return r.createElement("th",Object.assign({key:"column-"+t,className:"py-3 pr-2 space-x-6 text-xs font-medium tracking-wide text-left text-gray-500 uppercase"},e.getHeaderProps(e.getSortByToggleProps())),e.render("Header"),r.createElement("span",null,e.isSorted?r.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",className:"inline-block w-4 h-4 ml-2 text-gray-500"},r.createElement("path",e.isSortedDesc?{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"}:{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15l7-7 7 7"})):""))})))}))),r.createElement("tbody",Object.assign({},u(),{className:"bg-white divide-y divide-gray-200"}),m.map((function(e,t){return d(e),r.createElement(n.Transition,Object.assign({show:!0,enter:"transition ease-out duration-300",enterFrom:"transform opacity-40",enterTo:"transform opacity-100",leave:"transition ease-in duration-300",leaveFrom:"transform opacity-100",leaveTo:"transform opacity-0",as:"tr"},e.getRowProps(),{key:"row-"+t,className:"cursor-pointer hover:bg-gray-50",onClick:function(){return l(e.original)}}),e.cells.map((function(e,t){return r.createElement("td",Object.assign({className:"py-3 space-x-6 text-xs text-gray-900 truncate max-w-2xs whitespace-nowrap"},e.getCellProps(),{key:"cell-"+t}),e.render("Cell"))})))})))),o?r.createElement("table",{className:"min-w-full divide-y divide-gray-200"},Array.from(Array(12).keys()).map((function(e){return r.createElement(C,{key:e})}))):"")},_=function(e){var n=e.onChange,a=e.searchTerm,o=e.isSearchVisible,l=e.setIsSearchVisible,i=t.useRef(null),c=function(){o?(n(""),l(!1)):(l(!0),setTimeout((function(){var e;null==(e=i.current)||e.focus()}),0))};return o?r.createElement("div",{className:"h-5"},r.createElement("div",{className:"absolute w-full -inset-x-0 -top-2"},r.createElement("div",{className:"relative"},r.createElement("button",{className:"absolute right-2 top-2",onClick:function(){return c()}},r.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"w-5 h-5 text-gray-400 transition duration-150 hover:text-gray-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},r.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"}))),r.createElement("input",{className:"w-full px-3 py-2 mb-3 text-sm leading-tight text-gray-700 border border-gray-200 rounded shadow-sm appearance-none focus:outline-none focus:shadow-outline",name:"search",placeholder:"Search",autoComplete:"off",ref:i,onChange:function(e){return n(e.target.value)},value:a})))):r.createElement("button",{className:"",onClick:function(){return c()}},r.createElement("svg",{className:"w-5 h-5 text-gray-400 transition duration-150 hover:text-gray-500",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},r.createElement("path",{fillRule:"evenodd",d:"M8 4a4 4 0 100 8 4 4 0 000-8zM2 8a6 6 0 1110.89 3.476l4.817 4.817a1 1 0 01-1.414 1.414l-4.816-4.816A6 6 0 012 8z",clipRule:"evenodd"})))},F=function(e){return r.createElement(n.Transition,{show:e.open,as:t.Fragment},r.createElement("div",{className:"absolute bottom-0 left-0 right-0 rounded-t-2xl",style:{width:"calc(100% - 3rem)",left:"1.5rem"}},r.createElement(n.Transition.Child,{as:t.Fragment,enter:"transform transition ease-in-out duration-300",enterFrom:"translate-y-full",enterTo:"translate-y-0",leave:"transform transition ease-in-out duration-300",leaveFrom:"translate-y-0",leaveTo:"translate-y-full"},r.createElement("div",{className:"relative w-full rounded-t-2xl"},r.createElement("div",{className:"flex flex-col h-full py-6 overflow-y-auto border border-gray-200 rounded-t-lg shadow-sm bg-gray-50"},r.createElement("div",{className:"relative flex-1 px-4 sm:px-6"},e.children))))))},B=function(e){var n,a,o,i,c=e.appId,u=e.consumerId,m=e.jwt,d=e.serviceId,f=e.onSelect,h=t.useState("root"),v=h[0],g=h[1],y=t.useState([]),x=y[0],w=y[1],E=t.useState(null),b=E[0],S=E[1],L=t.useState(""),C=L[0],O=L[1],B=t.useState(),z=B[0],I=B[1],P=t.useState(!1),R=P[0],H=P[1],A=t.useState(!1),G=A[0],D=A[1],W=function(e,r){void 0===r&&(r=500);var n=t.useState(e),a=n[0],o=n[1],l=t.useRef(null),i=function(){null!==l.current&&clearInterval(l.current)};return t.useEffect((function(){return l.current=setTimeout((function(){o(e)}),r),i}),[e,r]),t.useEffect((function(){return i}),[]),a}(C),V=(o=d,i=t.useRef(),t.useEffect((function(){i.current=o}),[o]),i.current),$=null==W?void 0:W.length,q={"Content-Type":"application/json","x-apideck-auth-type":"JWT","x-apideck-app-id":c,"x-apideck-consumer-id":u,"x-apideck-service-id":d,Authorization:"Bearer "+m},J=N((function(e,t){var r,n,a,o="https://unify.apideck.com/file-storage/files?limit=30&"+("shared"===v?"filter[shared]=true":"filter[folder_id]="+v);return!t||null!=t&&null!=(r=t.data)&&r.length?0===e?o:o+"&cursor="+(null==t||null==(n=t.meta)||null==(a=n.cursors)?void 0:a.next):null}),function(){var e=s(p.mark((function e(t){var r;return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,fetch(t,{headers:q});case 2:return r=e.sent,e.next=5,r.json();case 5:return e.abrupt("return",e.sent);case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),{shouldRetryOnError:!1}),U=J.data,Y=J.setSize,Z=J.size,K=J.error;t.useEffect((function(){V&&V!==d&&Y(0)}),[d,V]);var Q=K||(null==U?void 0:U.length)&&(null==(n=U[U.length-1])?void 0:n.error),X=!U&&!K,ee=Z>0&&U&&void 0===U[Z-1],te=(null==U?void 0:U.map((function(e){return null==e?void 0:e.data})).flat())||[];if("root"===v&&null!=U&&U.length&&"google-drive"===d){var re,ne={id:"shared",name:"Shared with me",type:"folder"};null!=(re=te)&&re.length?te=[ne].concat(te):te.push(ne)}return t.useEffect((function(){null!=W&&W.length&&(H(!0),function(){var e=s(p.mark((function e(){var t;return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t={headers:q,method:"POST",body:JSON.stringify({query:W})},e.next=4,fetch("https://unify.apideck.com/file-storage/files/search",t);case 4:return e.abrupt("return",e.sent.json());case 6:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}()().then((function(e){I(e.data)})).finally((function(){return H(!1)})))}),[W]),r.createElement(t.Fragment,null,r.createElement("div",{className:"relative flex items-center mb-1 "+(null!=x&&x.length?"justify-between":"justify-end")},r.createElement(k,{folders:x,handleClick:function(e){if(e){g(e.id);var t=x.indexOf(e),r=[].concat(x.slice(0,t+1));w(r)}else g("root"),w([])}}),r.createElement(_,{onChange:function(e){console.log(e),O(e)},searchTerm:C,isSearchVisible:G,setIsSearchVisible:D})),R||!$||null!=z&&z.length?null:r.createElement("p",{className:"py-4 text-center text-gray-700"},"No results found"),X||R?r.createElement(T,null):r.createElement(M,{data:$&&z?z:te,handleSelect:function(e){"folder"===e.type&&(g(e.id),$?(O(""),D(!1),w([e])):w([].concat(x,[e]))),"file"===e.type&&S(e)},isLoadingMore:ee}),X?null:r.createElement(F,{open:!!b},r.createElement(j,{file:b,setFile:S,onSelect:f})),!X&&K?r.createElement("p",{className:"text-red-600"},(null==Q?void 0:Q.message)||Q):null,null==(a=te)||!a.length||ee||$?null:r.createElement("div",{className:"flex flex-row-reverse py-4 border-gray-200"},r.createElement(l.Waypoint,{onEnter:function(){var e,t,r;(null==U?void 0:U.length)&&(null==(e=U[U.length-1])||null==(t=e.meta)||null==(r=t.cursors)?void 0:r.next)&&Y(Z+1)}})))},z=function(e){return!!e.configured&&("oauth2"===e.auth_type?!(null==e||!e.revoke_url):function(e){var t=e.form_fields;if(0===(null==t?void 0:t.length))return!0;var r=t.filter((function(e){return e.required}));return 0===(null==r?void 0:r.length)||r.every((function(e){return""!==e.value}))}(e))},I=function(e){var t=e.className;return r.createElement("svg",{className:"text-blue-600 animate-spin "+(void 0===t?"w-8 h-8":t),xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24"},r.createElement("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),r.createElement("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"}))},P=function(e){var t=e.jwt,a=e.connections,o=e.connection,l=e.setConnection,i=e.isLoading,c=function(){var e=s(p.mark((function e(t){return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:z(t)||u(),l(t);case 2:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),u=function(){window.location.href="https://vault.apideck.com/integrations/crm/"+(null==o?void 0:o.service_id)+"/enable?jwt="+t},m=function(e){return e.enabled?z(e)?"bg-primary-500":"bg-yellow-400":"bg-gray-300"};return r.createElement("div",{className:"relative inline-block"},r.createElement(n.Menu,null,(function(e){var t=e.open;return r.createElement(r.Fragment,null,r.createElement(n.Menu.Button,{className:"flex items-center justify-between w-full px-4 py-2 text-sm font-medium text-blue-800 bg-blue-100 border border-blue-200 rounded-md group hover:bg-cool-gray-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-cool-gray-100 focus:ring-blue-600",style:{minWidth:180}},r.createElement("div",null,!i&&(null==o?void 0:o.icon)&&r.createElement("img",{className:"inline-block w-6 h-6 mr-2 rounded-full "+(i?"animate-spin opacity-20":""),src:!i&&null!=o&&o.icon?null==o?void 0:o.icon:"/img/logo.png",alt:""}),i&&r.createElement(I,{className:"w-6 h-6"}),!i&&r.createElement("span",null,(null==o?void 0:o.name)||"No integrations")),r.createElement("svg",{className:"w-5 h-5 ml-2 -mr-1",viewBox:"0 0 20 20",fill:"currentColor"},r.createElement("path",{fillRule:"evenodd",d:"M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z",clipRule:"evenodd"}))),r.createElement(n.Transition,{show:t,enter:"transition ease-out duration-100",enterFrom:"transform opacity-0 scale-95",enterTo:"transform opacity-100 scale-100",leave:"transition ease-in duration-75",leaveFrom:"transform opacity-100 scale-100",leaveTo:"transform opacity-0 scale-95",className:"min-w-sm"},r.createElement(n.Menu.Items,{static:!0,className:"absolute right-0 z-10 w-full mt-2 origin-top-right bg-white border divide-y rounded-md outline-none border-cool-gray-200 divide-cool-gray-100"},r.createElement("div",{className:"py-1"},null==a?void 0:a.map((function(e,t){return r.createElement(n.Menu.Item,{key:t},(function(t){return r.createElement("div",{onClick:function(){return c(e)},className:(t.active?"bg-gray-100 text-gray-900":"text-gray-600")+" flex items-center justify-between min-w-0 mx-2 cursor-pointer rounded-md py-0.5 overflow-hidden "+(e.enabled?"":"opacity-60")},r.createElement("img",{className:"flex-shrink-0 w-6 h-6 m-2 rounded-full",src:e.icon,alt:""}),r.createElement("span",{className:"flex-1 min-w-0"},r.createElement("span",{className:"text-sm font-medium text-gray-900 truncate"},e.name)),r.createElement("span",{className:"inline-block w-2.5 h-2.5 mr-2 rounded-full ring-2 ring-white "+m(e)}))}))})),r.createElement(n.Menu.Item,null,(function(e){return r.createElement("div",{onClick:function(){return u()},className:(e.active?"bg-gray-100 text-gray-900":"text-gray-600")+" flex items-center justify-between min-w-0 mx-2 cursor-pointer rounded-md py-0.5 overflow-hidden"},r.createElement("svg",{className:"flex-shrink-0 w-6 h-6 m-2",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},r.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6v6m0 0v6m0-6h6m-6 0H6"})),r.createElement("span",{className:"flex-1 min-w-0"},r.createElement("span",{className:"text-sm font-medium text-gray-900 truncate"},"Add integration")))}))))))})))},R=function(e){var n,a=e.appId,l=e.consumerId,i=e.jwt,c=e.onSelect,u=e.title,m=e.subTitle,d=t.useState(),f=d[0],h=d[1],v=o("https://unify.apideck.com/vault/connections",function(){var e=s(p.mark((function e(t){var r;return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,fetch(t,{headers:{"Content-Type":"application/json","x-apideck-consumer-id":"test-consumer-ckgrs95l3y4er0b99qa37buj2","x-apideck-app-id":"cfaZrORgaH2PMQpIcjTpfhERIpIEUJHev09ucjTp","x-apideck-auth-type":"JWT",Authorization:"Bearer "+i}});case 2:return r=e.sent,e.next=5,r.json();case 5:return e.abrupt("return",e.sent);case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),{shouldRetryOnError:!1}),g=v.data,y=v.error,x=!g&&!y,w=(null==g?void 0:g.error)||y,E=null==g||null==(n=g.data)?void 0:n.filter((function(e){return"callable"===e.state&&"file-storage"===e.unified_api}));return t.useEffect((function(){!f&&null!=E&&E.length&&h(E[0])}),[h,E]),r.createElement("div",{className:"-m-6 bg-white sm:rounded-lg h-modal"},r.createElement("div",{className:"flex items-center justify-between px-4 py-5 sm:px-6"},r.createElement("div",null,r.createElement("h3",{className:"text-lg font-medium leading-6 text-gray-900"},u),r.createElement("p",{className:"max-w-2xl mt-1 text-sm text-gray-500"},w?r.createElement("span",{className:"mb-2 text-red-600"},w):r.createElement("span",{className:"text-gray-700 dark:text-gray-400"},f?m:"No connector selected"))),r.createElement(P,{jwt:i,connections:E,connection:f,setConnection:h,isLoading:x})),r.createElement("div",{className:"px-4 py-5 overflow-y-auto border-t border-gray-200 sm:px-6",style:{maxHeight:"80%"}},f?r.createElement(B,{appId:a,consumerId:l,serviceId:f.service_id,jwt:i,onSelect:c}):null!=E&&E.length||x?null:r.createElement("div",{className:"flex items-center justify-center border-4 border-gray-200 border-dashed rounded-lg h-96"},r.createElement("div",{className:"text-center"},r.createElement("a",{href:"https://vault.apideck.com/session/"+i,target:"_blank",rel:"noreferrer",className:"text-indigo-600 hover:text-indigo-900"},"Go to vault")," ","to add file storage connectors"))))};exports.FilePicker=t.forwardRef((function(e,n){var a=e.appId,o=e.consumerId,l=e.jwt,i=e.trigger,c=e.onSelect,s=e.title,u=void 0===s?"Apideck File Picker":s,m=e.subTitle,d=void 0===m?"Select a file":m,p=t.useState(!1),h=p[0],v=p[1];return r.createElement(t.Fragment,null,r.cloneElement(i,{onClick:function(){return v(!0)},ref:n}),r.createElement(f,{isOpen:h,onClose:function(){return v(!1)}},r.createElement(R,{appId:a,consumerId:o,jwt:l,onSelect:function(e){c(e),v(!1)},title:u,subTitle:d})))}));
//# sourceMappingURL=file-picker.cjs.production.min.js.map
{
"version": "0.1.5-0",
"version": "0.1.6",
"license": "MIT",

@@ -31,8 +31,7 @@ "main": "dist/index.js",

"react-table": "^7.7.0",
"react-waypoint": "^10.1.0",
"swr": "^1.0.0"
},
"husky": {
"hooks": {
"pre-commit": "tsdx lint src/**/*.tsx"
}
"hooks": {}
},

@@ -39,0 +38,0 @@ "prettier": {

@@ -1,181 +0,49 @@

# TSDX React w/ Storybook User Guide
# Apideck File Picker
Congrats! You just saved yourself hours of work by bootstrapping this project with TSDX. Let’s get you oriented with what’s here and how to use it.
A React file picker component that works with the Apideck [File Storage API](https://developers.apideck.com/apis/file-storage/reference).
> This TSDX setup is meant for developing React component libraries (not apps!) that can be published to NPM. If you’re looking to build a React-based app, you should use `create-react-app`, `razzle`, `nextjs`, `gatsby`, or `react-static`.
Sign up for a free account at [apideck.com](https://app.apideck.com/signup) to obtain an API key and App ID.
> If you’re new to TypeScript and React, checkout [this handy cheatsheet](https://github.com/sw-yx/react-typescript-cheatsheet/)
## Usage
## Commands
Install the component
TSDX scaffolds your new library inside `/src`, and also sets up a [Parcel-based](https://parceljs.org) playground for it inside `/example`.
The recommended workflow is to run TSDX in one terminal:
```bash
npm start # or yarn start
```sh
yarn add @apideck/file-picker
```
This builds to `/dist` and runs the project in watch mode so any edits you save inside `src` causes a rebuild to `/dist`.
Create a [Vault session](https://developers.apideck.com/apis/vault/reference#operation/sessionsCreate) inside your application to get a JSON Web Token.
Then run either Storybook or the example playground:
Pass the JWT together with your App ID and a consumer ID to the FilePicker component
### Storybook
```js
import { FilePicker } from '@apideck/file-picker'
import '@apideck/file-picker/dist/styles.css'
Run inside another terminal:
const MyComponent = () => {
const handleSelect = (file) => {
console.log(file)
}
```bash
yarn storybook
return (
<FilePicker
onSelect={handleSelect}
trigger={<button>Pick a file</button>}
jwt="token-123"
appId="your-app-id"
consumerId="your-consumer-id"
/>
)
}
```
This loads the stories from `./stories`.
### Using Tailwind?
> NOTE: Stories should reference the components as if using the library, similar to the example playground. This means importing from the root project directory. This has been aliased in the tsconfig and the storybook webpack config as a helper.
The FilePicker is styled using [Tailwind CSS](https://tailwindcss.com/). If you were to use the File Picker component in a project that also uses Tailwind CSS, you can omit the CSS file import, and include the package in the purge path of the tailwind.config.css.
### Example
Then run the example inside another:
```bash
cd example
npm i # or yarn to install dependencies
npm start # or yarn start
```
The default example imports and live reloads whatever is in `/dist`, so if you are seeing an out of date component, make sure TSDX is running in watch mode like we recommend above. **No symlinking required**, we use [Parcel's aliasing](https://parceljs.org/module_resolution.html#aliases).
To do a one-off build, use `npm run build` or `yarn build`.
To run tests, use `npm test` or `yarn test`.
## Configuration
Code quality is set up for you with `prettier`, `husky`, and `lint-staged`. Adjust the respective fields in `package.json` accordingly.
### Jest
Jest tests are set up to run with `npm test` or `yarn test`.
### Bundle analysis
Calculates the real cost of your library using [size-limit](https://github.com/ai/size-limit) with `npm run size` and visulize it with `npm run analyze`.
#### Setup Files
This is the folder structure we set up for you:
```txt
/example
index.html
index.tsx # test your component here in a demo app
package.json
tsconfig.json
/src
index.tsx # EDIT THIS
/test
blah.test.tsx # EDIT THIS
/stories
Thing.stories.tsx # EDIT THIS
/.storybook
main.js
preview.js
.gitignore
package.json
README.md # EDIT THIS
tsconfig.json
```
#### React Testing Library
We do not set up `react-testing-library` for you yet, we welcome contributions and documentation on this.
### Rollup
TSDX uses [Rollup](https://rollupjs.org) as a bundler and generates multiple rollup configs for various module formats and build settings. See [Optimizations](#optimizations) for details.
### TypeScript
`tsconfig.json` is set up to interpret `dom` and `esnext` types, as well as `react` for `jsx`. Adjust according to your needs.
## Continuous Integration
### GitHub Actions
Two actions are added by default:
- `main` which installs deps w/ cache, lints, tests, and builds on all pushes against a Node and OS matrix
- `size` which comments cost comparison of your library on every pull request using [size-limit](https://github.com/ai/size-limit)
## Optimizations
Please see the main `tsdx` [optimizations docs](https://github.com/palmerhq/tsdx#optimizations). In particular, know that you can take advantage of development-only optimizations:
```js
// ./types/index.d.ts
declare var __DEV__: boolean;
// inside your code...
if (__DEV__) {
console.log('foo');
}
// tailwind.config.js
purge: [
'./node_modules/@apideck/file-picker/dist/*.js',
],
```
You can also choose to install and use [invariant](https://github.com/palmerhq/tsdx#invariant) and [warning](https://github.com/palmerhq/tsdx#warning) functions.
## Module Formats
CJS, ESModules, and UMD module formats are supported.
The appropriate paths are configured in `package.json` and `dist/index.js` accordingly. Please report if any issues are found.
## Deploying the Example Playground
The Playground is just a simple [Parcel](https://parceljs.org) app, you can deploy it anywhere you would normally deploy that. Here are some guidelines for **manually** deploying with the Netlify CLI (`npm i -g netlify-cli`):
```bash
cd example # if not already in the example folder
npm run build # builds to dist
netlify deploy # deploy the dist folder
```
Alternatively, if you already have a git repo connected, you can set up continuous deployment with Netlify:
```bash
netlify init
# build command: yarn build && cd example && yarn && yarn build
# directory to deploy: example/dist
# pick yes for netlify.toml
```
## Named Exports
Per Palmer Group guidelines, [always use named exports.](https://github.com/palmerhq/typescript#exports) Code split inside your React app instead of your React library.
## Including Styles
There are many ways to ship styles, including with CSS-in-JS. TSDX has no opinion on this, configure how you like.
For vanilla CSS, you can include it at the root directory and add it to the `files` section in your `package.json`, so that it can be imported separately by your users and run through their bundler's loader.
## Publishing to NPM
We recommend using [np](https://github.com/sindresorhus/np).
## Usage with Lerna
When creating a new package with TSDX within a project set up with Lerna, you might encounter a `Cannot resolve dependency` error when trying to run the `example` project. To fix that you will need to make changes to the `package.json` file _inside the `example` directory_.
The problem is that due to the nature of how dependencies are installed in Lerna projects, the aliases in the example project's `package.json` might not point to the right place, as those dependencies might have been installed in the root of your Lerna project.
Change the `alias` to point to where those packages are actually installed. This depends on the directory structure of your Lerna project, so the actual path might be different from the diff below.
```diff
"alias": {
- "react": "../node_modules/react",
- "react-dom": "../node_modules/react-dom"
+ "react": "../../../node_modules/react",
+ "react-dom": "../../../node_modules/react-dom"
},
```
An alternative to fixing this problem would be to remove aliases altogether and define the dependencies referenced as aliases as dev dependencies instead. [However, that might cause other problems.](https://github.com/palmerhq/tsdx/issues/64)

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc