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

@vizzly/components

Package Overview
Dependencies
Maintainers
1
Versions
222
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vizzly/components - npm Package Compare versions

Comparing version 0.0.82 to 0.0.83

13

dist/components.cjs.development.js

@@ -736,2 +736,9 @@ 'use strict';

var setSavedAt = function setSavedAt(state, setState, savedAt) {
setState(_extends({}, state, {
version: _extends({}, state.version, {
savedAt: savedAt
})
}));
};
var setTitle = function setTitle(state, setState, title) {

@@ -820,3 +827,4 @@ setState(_extends({}, state, {

setLibraryVersion: noOp,
setVersion: noOp
setVersion: noOp,
setSavedAt: noOp
});

@@ -904,2 +912,5 @@ var ComponentContextProvider = function ComponentContextProvider(props) {

return setVersion(state, setState, version);
},
setSavedAt: function setSavedAt$1(savedAt) {
return setSavedAt(state, setState, savedAt);
}

@@ -906,0 +917,0 @@ });

2

dist/components.cjs.production.min.js

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

"use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),r=t(e),n=require("@vizzly/puppet"),o=require("lodash"),i=t(require("isomorphic-fetch"));function u(){u=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",s=n.toStringTag||"@@toStringTag";function a(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{a({},"")}catch(t){a=function(t,e,r){return t[e]=r}}function c(t,e,r,n){var o=Object.create((e&&e.prototype instanceof p?e:p).prototype),i=new L(n||[]);return o._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var u=r.delegate;if(u){var s=b(u,r);if(s){if(s===l)continue;return s}}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 a=f(t,e,r);if("normal"===a.type){if(n=r.done?"completed":"suspendedYield",a.arg===l)continue;return{value:a.arg,done:r.done}}"throw"===a.type&&(n="completed",r.method="throw",r.arg=a.arg)}}}(t,r,i),o}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=c;var l={};function p(){}function h(){}function v(){}var d={};a(d,o,(function(){return this}));var m=Object.getPrototypeOf,y=m&&m(m(P([])));y&&y!==e&&r.call(y,o)&&(d=y);var g=v.prototype=p.prototype=Object.create(d);function w(t){["next","throw","return"].forEach((function(e){a(t,e,(function(t){return this._invoke(e,t)}))}))}function x(t,e){var n;this._invoke=function(o,i){function u(){return new e((function(n,u){!function n(o,i,u,s){var a=f(t[o],t,i);if("throw"!==a.type){var c=a.arg,l=c.value;return l&&"object"==typeof l&&r.call(l,"__await")?e.resolve(l.__await).then((function(t){n("next",t,u,s)}),(function(t){n("throw",t,u,s)})):e.resolve(l).then((function(t){c.value=t,u(c)}),(function(t){return n("throw",t,u,s)}))}s(a.arg)}(o,i,n,u)}))}return n=n?n.then(u,u):u()}}function b(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,b(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=f(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,l;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function C(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function E(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function L(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(C,this),this.reset(!0)}function P(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:O}}function O(){return{value:void 0,done:!0}}return h.prototype=v,a(g,"constructor",v),a(v,"constructor",h),h.displayName=a(v,s,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,v):(t.__proto__=v,a(t,s,"GeneratorFunction")),t.prototype=Object.create(g),t},t.awrap=function(t){return{__await:t}},w(x.prototype),a(x.prototype,i,(function(){return this})),t.AsyncIterator=x,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var u=new x(c(e,r,n,o),i);return t.isGeneratorFunction(r)?u:u.next().then((function(t){return t.done?t.value:u.next()}))},w(g),a(g,s,"Generator"),a(g,o,(function(){return this})),a(g,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=P,L.prototype={constructor:L,reset:function(t){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(E),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return u.type="throw",u.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],u=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var s=r.call(i,"catchLoc"),a=r.call(i,"finallyLoc");if(s&&a){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!a)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var u=i?i.completion:{};return u.type=t,u.arg=e,i?(this.method="next",this.next=i.finallyLoc,l):this.complete(u)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),E(r),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;E(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:P(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}function s(t,e,r,n,o,i,u){try{var s=t[i](u),a=s.value}catch(t){return void r(t)}s.done?e(a):Promise.resolve(a).then(n,o)}function a(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function u(t){s(i,n,o,u,a,"next",t)}function a(t){s(i,n,o,u,a,"throw",t)}u(void 0)}))}}function c(){return(c=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t}).apply(this,arguments)}var f=function(t){return{id:t.id,dataType:t.type,title:t.title}},l=function(t){return{fields:[].concat(t.fields).map(f)}},p=function(t){var e=t.versions.map((function(t){return{type:t.frontend_context.type,title:t.title,description:t.description,props:t.frontend_context.props,libraryVersion:t.frontend_context.libraryVersion,secureFilters:t.secure_filters.map((function(t){return{field:t.field,op:t.operator}})),savedAt:t.inserted_at}}));return{id:t.id,dataSets:t.data_sets.map(l),versions:e}},h=function(t){return o.last(t.versions)},v=function(t){return function(){var e=a(u().mark((function e(r,n){var o,i;return u().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t({path:r,method:"get",headers:c({},n)});case 2:if(i=(o=e.sent).body,200!=o.status){e.next=7;break}return e.abrupt("return",i);case 7:return e.abrupt("return",void 0);case 8:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}()},d=function(t){return t.content=t.content.map((function(e){return e.map((function(e,r){return function(t,e){if(null===t)return null;switch(e){case"date_time":return new Date(t);case"number":case"string":return t;case"boolean":return!!t}throw"Cannot parse value of unrecognised type."}(e,t.fields[r].dataType)}))})),t},m=function(t){return function(){var e=a(u().mark((function e(r,n,o){var i,s;return u().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t({path:"/api/create-result",method:"post",body:{queries:n.map((function(t){return y(t,r)}))},abortSignal:o});case 2:if(s=(i=e.sent).body,200!=i.status){e.next=7;break}return e.abrupt("return",s.results.map(d));case 7:return e.abrupt("return",void 0);case 8:case"end":return e.stop()}}),e)})));return function(t,r,n){return e.apply(this,arguments)}}()},y=function(t,e){var r=t.timeDimension;return r&&(r=c({},r,{timeZone:n.Utils.DateTime.currentTimezone()})),c({},t,{componentId:e,timeDimension:r})},g=function(t,r,n,i){e.useEffect((function(){var e=new AbortController,s=function(){var o=a(u().mark((function o(){var s;return u().wrap((function(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,t.createQueryResult(n,r,e.signal);case 2:(s=o.sent)&&i(s,r);case 4:case"end":return o.stop()}}),o)})));return function(){return o.apply(this,arguments)}}();return n&&!o.isEmpty(r)&&s(),function(){e.abort()}}),[JSON.stringify(n),JSON.stringify(r)])},w=function(t){if(!t)return null;var e,r=function(t){return function(){var e=a(u().mark((function e(r){var n,o,s;return u().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.authToken?{auth:"Bearer "+t.authToken}:{},o=r.headers||{},e.next=4,i(""+t.host+r.path,{method:r.method,headers:c({"Content-Type":"application/json",Accept:"application/json"},n,o),redirect:"follow",referrerPolicy:"no-referrer",body:r.body?JSON.stringify(r.body):null,signal:r.abortSignal});case 4:return s=e.sent,e.next=7,s.json();case 7:return e.abrupt("return",{body:e.sent,status:s.status});case 9:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()}(t);return{config:t,getComponent:(e=r,function(){var t=a(u().mark((function t(r){var n,o;return u().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e({path:"/api/component/"+r,method:"get"});case 2:if(o=(n=t.sent).body,200!=n.status){t.next=7;break}return t.abrupt("return",p(o));case 7:return t.abrupt("return",void 0);case 8:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),getComponentAuth:v(r),createQueryResult:m(r)}},x=function(){throw"Function not initialised."},b=r.createContext({component:null,version:null,apiConfig:null,results:[],queries:[],setResults:x,setProps:x,setStyleProps:x,setTitle:x,setChartType:x,setDescription:x,setLibraryVersion:x,setVersion:x}),C=function(){return r.useContext(b)},E=function(){return r.useContext(b)},L=function(){return r.useContext(b)},P=function(){return r.useContext(b)},O=function(t,e,r,n,o,i){var u={measure:t,order:e,filter:r,dimension:n,timeDimension:o,limit:i};return _(u)?u:null},_=function(t){return null!==t&&!o.isEmpty(t.measure)},j=function(t,e,r,n){var o=O(r.measure,r.order,r.filter,r.dimension,r.timeDimension,r.limit);g(w(t),_(o)?[o]:[],null==e?void 0:e.id,n)},q=function(t,e,r,n){var o=O(r.measure,r.order,r.filter,r.dimension,r.timeDimension,r.limit);g(w(t),_(o)?[o]:[],null==e?void 0:e.id,n)},S=function(t,e,r,n){var o=O(r.measure,r.order,r.filter,r.dimension,r.timeDimension,r.limit);g(w(t),_(o)?[o]:[],null==e?void 0:e.id,n)},k=function(t,e,r,n){var o=[];r.xMeasure&&o.push(r.xMeasure),r.yMeasure&&o.push(r.yMeasure);var i=O(o,r.order,r.filter,r.dimension,r.timeDimension,r.limit);g(w(t),_(i)?[i]:[],null==e?void 0:e.id,n)};exports.AreaChart=function(t){var e=L(),i=e.apiConfig,u=e.component,s=e.setResults,a=e.results,c=e.queries,f=e.version,l=n.mergeProps(t,null==f?void 0:f.props,n.Components.LineChartView.defaultProps);return S(i,u,l,s),o.isEmpty(a)?null:r.createElement(n.Components.AreaChartView,Object.assign({},l,{result:a[0],query:c[0]}))},exports.BarChart=function(t){var e=E(),i=e.apiConfig,u=e.results,s=e.component,a=e.queries,c=e.version,f=e.setResults,l=n.mergeProps(t,null==c?void 0:c.props,n.Components.LineChartView.defaultProps);return q(i,s,l,f),o.isEmpty(u)?null:r.createElement(n.Components.BarChartView,Object.assign({},l,{result:u[0],query:a[0]}))},exports.ComponentContextProvider=function(t){var n=t.children,o=t.apiConfig,i=t.componentId,s=r.useState({apiConfig:o,results:[],queries:[],component:null,version:null}),f=s[0],l=s[1];e.useEffect((function(){!function(){var t=a(u().mark((function t(){var e,r,n;return u().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,null==(e=w(o))?void 0:e.getComponent(i);case 2:(r=t.sent)&&(n=h(r),l(c({},f,{queries:[],results:[],component:r,version:n||null})));case 4:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}()()}),[i]);var p=c({},f,{setChartType:function(t){return function(t,e,r){e(c({},t,{results:[],queries:[],version:c({},t.version,{type:r})}))}(f,l,t)},setDescription:function(t){return function(t,e,r){e(c({},t,{version:c({},t.version,{description:r})}))}(f,l,t)},setTitle:function(t){return function(t,e,r){e(c({},t,{version:c({},t.version,{title:r})}))}(f,l,t)},setLibraryVersion:function(t){return function(t,e,r){e(c({},t,{results:[],queries:[],version:c({},t.version,{libraryVersion:r})}))}(f,l,t)},setProps:function(t){return function(t,e,r){e(c({},t,{results:[],queries:[],version:c({},t.version,{props:c({},r)})}))}(f,l,t)},setStyleProps:function(t){return function(t,e,r){e(c({},t,{version:c({},t.version,{props:c({},r)})}))}(f,l,t)},setResults:function(t,e){return function(t,e,r,n){e(c({},t,{results:r,queries:n}))}(f,l,t,e)},setVersion:function(t){return function(t,e,r){e(c({},t,{version:r,results:[],queries:[]}))}(f,l,t)}});return r.createElement(b.Provider,{value:p},n)},exports.LineChart=function(t){var e=C(),i=e.apiConfig,u=e.results,s=e.queries,a=e.version,c=e.component,f=e.setResults,l=n.mergeProps(t,null==a?void 0:a.props,n.Components.LineChartView.defaultProps);return j(i,c,l,f),o.isEmpty(u)?null:r.createElement(n.Components.LineChartView,Object.assign({},l,{result:u[0],query:s[0]}))},exports.ScatterChart=function(t){var e=P(),i=e.apiConfig,u=e.setResults,s=e.component,a=e.results,c=e.queries,f=e.version,l=n.mergeProps(t,null==f?void 0:f.props,n.Components.LineChartView.defaultProps);return k(i,s,l,u),o.isEmpty(a)?null:r.createElement(n.Components.ScatterChartView,Object.assign({},l,{result:a[0],query:c[0]}))},exports.createQueryResult=m,exports.useAreaChart=L,exports.useAreaChartQueryEffect=S,exports.useBarChart=E,exports.useBarChartQueryEffect=q,exports.useComponentContext=function(){return r.useContext(b)},exports.useLineChart=C,exports.useLineChartQueryEffect=j,exports.useScatterChart=P,exports.useScatterChartQueryEffect=k;
"use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),r=t(e),n=require("@vizzly/puppet"),o=require("lodash"),i=t(require("isomorphic-fetch"));function u(){u=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",s=n.toStringTag||"@@toStringTag";function a(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{a({},"")}catch(t){a=function(t,e,r){return t[e]=r}}function c(t,e,r,n){var o=Object.create((e&&e.prototype instanceof p?e:p).prototype),i=new L(n||[]);return o._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var u=r.delegate;if(u){var s=b(u,r);if(s){if(s===l)continue;return s}}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 a=f(t,e,r);if("normal"===a.type){if(n=r.done?"completed":"suspendedYield",a.arg===l)continue;return{value:a.arg,done:r.done}}"throw"===a.type&&(n="completed",r.method="throw",r.arg=a.arg)}}}(t,r,i),o}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=c;var l={};function p(){}function h(){}function v(){}var d={};a(d,o,(function(){return this}));var m=Object.getPrototypeOf,y=m&&m(m(P([])));y&&y!==e&&r.call(y,o)&&(d=y);var g=v.prototype=p.prototype=Object.create(d);function w(t){["next","throw","return"].forEach((function(e){a(t,e,(function(t){return this._invoke(e,t)}))}))}function x(t,e){var n;this._invoke=function(o,i){function u(){return new e((function(n,u){!function n(o,i,u,s){var a=f(t[o],t,i);if("throw"!==a.type){var c=a.arg,l=c.value;return l&&"object"==typeof l&&r.call(l,"__await")?e.resolve(l.__await).then((function(t){n("next",t,u,s)}),(function(t){n("throw",t,u,s)})):e.resolve(l).then((function(t){c.value=t,u(c)}),(function(t){return n("throw",t,u,s)}))}s(a.arg)}(o,i,n,u)}))}return n=n?n.then(u,u):u()}}function b(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,b(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=f(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,l;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function C(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function E(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function L(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(C,this),this.reset(!0)}function P(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:O}}function O(){return{value:void 0,done:!0}}return h.prototype=v,a(g,"constructor",v),a(v,"constructor",h),h.displayName=a(v,s,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,v):(t.__proto__=v,a(t,s,"GeneratorFunction")),t.prototype=Object.create(g),t},t.awrap=function(t){return{__await:t}},w(x.prototype),a(x.prototype,i,(function(){return this})),t.AsyncIterator=x,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var u=new x(c(e,r,n,o),i);return t.isGeneratorFunction(r)?u:u.next().then((function(t){return t.done?t.value:u.next()}))},w(g),a(g,s,"Generator"),a(g,o,(function(){return this})),a(g,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=P,L.prototype={constructor:L,reset:function(t){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(E),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return u.type="throw",u.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],u=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var s=r.call(i,"catchLoc"),a=r.call(i,"finallyLoc");if(s&&a){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!a)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var u=i?i.completion:{};return u.type=t,u.arg=e,i?(this.method="next",this.next=i.finallyLoc,l):this.complete(u)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),E(r),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;E(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:P(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}function s(t,e,r,n,o,i,u){try{var s=t[i](u),a=s.value}catch(t){return void r(t)}s.done?e(a):Promise.resolve(a).then(n,o)}function a(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function u(t){s(i,n,o,u,a,"next",t)}function a(t){s(i,n,o,u,a,"throw",t)}u(void 0)}))}}function c(){return(c=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t}).apply(this,arguments)}var f=function(t){return{id:t.id,dataType:t.type,title:t.title}},l=function(t){return{fields:[].concat(t.fields).map(f)}},p=function(t){var e=t.versions.map((function(t){return{type:t.frontend_context.type,title:t.title,description:t.description,props:t.frontend_context.props,libraryVersion:t.frontend_context.libraryVersion,secureFilters:t.secure_filters.map((function(t){return{field:t.field,op:t.operator}})),savedAt:t.inserted_at}}));return{id:t.id,dataSets:t.data_sets.map(l),versions:e}},h=function(t){return o.last(t.versions)},v=function(t){return function(){var e=a(u().mark((function e(r,n){var o,i;return u().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t({path:r,method:"get",headers:c({},n)});case 2:if(i=(o=e.sent).body,200!=o.status){e.next=7;break}return e.abrupt("return",i);case 7:return e.abrupt("return",void 0);case 8:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}()},d=function(t){return t.content=t.content.map((function(e){return e.map((function(e,r){return function(t,e){if(null===t)return null;switch(e){case"date_time":return new Date(t);case"number":case"string":return t;case"boolean":return!!t}throw"Cannot parse value of unrecognised type."}(e,t.fields[r].dataType)}))})),t},m=function(t){return function(){var e=a(u().mark((function e(r,n,o){var i,s;return u().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t({path:"/api/create-result",method:"post",body:{queries:n.map((function(t){return y(t,r)}))},abortSignal:o});case 2:if(s=(i=e.sent).body,200!=i.status){e.next=7;break}return e.abrupt("return",s.results.map(d));case 7:return e.abrupt("return",void 0);case 8:case"end":return e.stop()}}),e)})));return function(t,r,n){return e.apply(this,arguments)}}()},y=function(t,e){var r=t.timeDimension;return r&&(r=c({},r,{timeZone:n.Utils.DateTime.currentTimezone()})),c({},t,{componentId:e,timeDimension:r})},g=function(t,r,n,i){e.useEffect((function(){var e=new AbortController,s=function(){var o=a(u().mark((function o(){var s;return u().wrap((function(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,t.createQueryResult(n,r,e.signal);case 2:(s=o.sent)&&i(s,r);case 4:case"end":return o.stop()}}),o)})));return function(){return o.apply(this,arguments)}}();return n&&!o.isEmpty(r)&&s(),function(){e.abort()}}),[JSON.stringify(n),JSON.stringify(r)])},w=function(t){if(!t)return null;var e,r=function(t){return function(){var e=a(u().mark((function e(r){var n,o,s;return u().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.authToken?{auth:"Bearer "+t.authToken}:{},o=r.headers||{},e.next=4,i(""+t.host+r.path,{method:r.method,headers:c({"Content-Type":"application/json",Accept:"application/json"},n,o),redirect:"follow",referrerPolicy:"no-referrer",body:r.body?JSON.stringify(r.body):null,signal:r.abortSignal});case 4:return s=e.sent,e.next=7,s.json();case 7:return e.abrupt("return",{body:e.sent,status:s.status});case 9:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()}(t);return{config:t,getComponent:(e=r,function(){var t=a(u().mark((function t(r){var n,o;return u().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e({path:"/api/component/"+r,method:"get"});case 2:if(o=(n=t.sent).body,200!=n.status){t.next=7;break}return t.abrupt("return",p(o));case 7:return t.abrupt("return",void 0);case 8:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),getComponentAuth:v(r),createQueryResult:m(r)}},x=function(){throw"Function not initialised."},b=r.createContext({component:null,version:null,apiConfig:null,results:[],queries:[],setResults:x,setProps:x,setStyleProps:x,setTitle:x,setChartType:x,setDescription:x,setLibraryVersion:x,setVersion:x,setSavedAt:x}),C=function(){return r.useContext(b)},E=function(){return r.useContext(b)},L=function(){return r.useContext(b)},P=function(){return r.useContext(b)},O=function(t,e,r,n,o,i){var u={measure:t,order:e,filter:r,dimension:n,timeDimension:o,limit:i};return _(u)?u:null},_=function(t){return null!==t&&!o.isEmpty(t.measure)},j=function(t,e,r,n){var o=O(r.measure,r.order,r.filter,r.dimension,r.timeDimension,r.limit);g(w(t),_(o)?[o]:[],null==e?void 0:e.id,n)},S=function(t,e,r,n){var o=O(r.measure,r.order,r.filter,r.dimension,r.timeDimension,r.limit);g(w(t),_(o)?[o]:[],null==e?void 0:e.id,n)},q=function(t,e,r,n){var o=O(r.measure,r.order,r.filter,r.dimension,r.timeDimension,r.limit);g(w(t),_(o)?[o]:[],null==e?void 0:e.id,n)},k=function(t,e,r,n){var o=[];r.xMeasure&&o.push(r.xMeasure),r.yMeasure&&o.push(r.yMeasure);var i=O(o,r.order,r.filter,r.dimension,r.timeDimension,r.limit);g(w(t),_(i)?[i]:[],null==e?void 0:e.id,n)};exports.AreaChart=function(t){var e=L(),i=e.apiConfig,u=e.component,s=e.setResults,a=e.results,c=e.queries,f=e.version,l=n.mergeProps(t,null==f?void 0:f.props,n.Components.LineChartView.defaultProps);return q(i,u,l,s),o.isEmpty(a)?null:r.createElement(n.Components.AreaChartView,Object.assign({},l,{result:a[0],query:c[0]}))},exports.BarChart=function(t){var e=E(),i=e.apiConfig,u=e.results,s=e.component,a=e.queries,c=e.version,f=e.setResults,l=n.mergeProps(t,null==c?void 0:c.props,n.Components.LineChartView.defaultProps);return S(i,s,l,f),o.isEmpty(u)?null:r.createElement(n.Components.BarChartView,Object.assign({},l,{result:u[0],query:a[0]}))},exports.ComponentContextProvider=function(t){var n=t.children,o=t.apiConfig,i=t.componentId,s=r.useState({apiConfig:o,results:[],queries:[],component:null,version:null}),f=s[0],l=s[1];e.useEffect((function(){!function(){var t=a(u().mark((function t(){var e,r,n;return u().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,null==(e=w(o))?void 0:e.getComponent(i);case 2:(r=t.sent)&&(n=h(r),l(c({},f,{queries:[],results:[],component:r,version:n||null})));case 4:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}()()}),[i]);var p=c({},f,{setChartType:function(t){return function(t,e,r){e(c({},t,{results:[],queries:[],version:c({},t.version,{type:r})}))}(f,l,t)},setDescription:function(t){return function(t,e,r){e(c({},t,{version:c({},t.version,{description:r})}))}(f,l,t)},setTitle:function(t){return function(t,e,r){e(c({},t,{version:c({},t.version,{title:r})}))}(f,l,t)},setLibraryVersion:function(t){return function(t,e,r){e(c({},t,{results:[],queries:[],version:c({},t.version,{libraryVersion:r})}))}(f,l,t)},setProps:function(t){return function(t,e,r){e(c({},t,{results:[],queries:[],version:c({},t.version,{props:c({},r)})}))}(f,l,t)},setStyleProps:function(t){return function(t,e,r){e(c({},t,{version:c({},t.version,{props:c({},r)})}))}(f,l,t)},setResults:function(t,e){return function(t,e,r,n){e(c({},t,{results:r,queries:n}))}(f,l,t,e)},setVersion:function(t){return function(t,e,r){e(c({},t,{version:r,results:[],queries:[]}))}(f,l,t)},setSavedAt:function(t){return function(t,e,r){e(c({},t,{version:c({},t.version,{savedAt:r})}))}(f,l,t)}});return r.createElement(b.Provider,{value:p},n)},exports.LineChart=function(t){var e=C(),i=e.apiConfig,u=e.results,s=e.queries,a=e.version,c=e.component,f=e.setResults,l=n.mergeProps(t,null==a?void 0:a.props,n.Components.LineChartView.defaultProps);return j(i,c,l,f),o.isEmpty(u)?null:r.createElement(n.Components.LineChartView,Object.assign({},l,{result:u[0],query:s[0]}))},exports.ScatterChart=function(t){var e=P(),i=e.apiConfig,u=e.setResults,s=e.component,a=e.results,c=e.queries,f=e.version,l=n.mergeProps(t,null==f?void 0:f.props,n.Components.LineChartView.defaultProps);return k(i,s,l,u),o.isEmpty(a)?null:r.createElement(n.Components.ScatterChartView,Object.assign({},l,{result:a[0],query:c[0]}))},exports.createQueryResult=m,exports.useAreaChart=L,exports.useAreaChartQueryEffect=q,exports.useBarChart=E,exports.useBarChartQueryEffect=S,exports.useComponentContext=function(){return r.useContext(b)},exports.useLineChart=C,exports.useLineChartQueryEffect=j,exports.useScatterChart=P,exports.useScatterChartQueryEffect=k;
//# sourceMappingURL=components.cjs.production.min.js.map

@@ -729,2 +729,9 @@ import React, { useEffect } from 'react';

var setSavedAt = function setSavedAt(state, setState, savedAt) {
setState(_extends({}, state, {
version: _extends({}, state.version, {
savedAt: savedAt
})
}));
};
var setTitle = function setTitle(state, setState, title) {

@@ -813,3 +820,4 @@ setState(_extends({}, state, {

setLibraryVersion: noOp,
setVersion: noOp
setVersion: noOp,
setSavedAt: noOp
});

@@ -897,2 +905,5 @@ var ComponentContextProvider = function ComponentContextProvider(props) {

return setVersion(state, setState, version);
},
setSavedAt: function setSavedAt$1(savedAt) {
return setSavedAt(state, setState, savedAt);
}

@@ -899,0 +910,0 @@ });

@@ -6,2 +6,3 @@ import { VizzlyPuppet } from '@vizzly/puppet';

declare type SetStateCallback = (state: State) => void;
export declare const setSavedAt: (state: State, setState: SetStateCallback, savedAt: string) => void;
export declare const setTitle: (state: State, setState: SetStateCallback, title: string) => void;

@@ -8,0 +9,0 @@ export declare const setDescription: (state: State, setState: SetStateCallback, description: string) => void;

@@ -19,3 +19,4 @@ import { VizzlyPuppet } from '@vizzly/puppet';

setStyleProps: (styleProps: ComponentProps) => void;
setSavedAt: (savedAt: string) => void;
}
export declare type ComponentContextType<ComponentProps> = ComponentContextState<ComponentProps> & ComponentContextMethods<ComponentProps>;
{
"name": "@vizzly/components",
"author": "James Bowers",
"version": "0.0.82",
"version": "0.0.83",
"license": "MIT",

@@ -6,0 +6,0 @@ "main": "dist/index.js",

@@ -8,2 +8,16 @@ import { VizzlyPuppet } from '@vizzly/puppet';

export const setSavedAt = (
state: State,
setState: SetStateCallback,
savedAt: string
): void => {
setState({
...state,
version: {
...(state.version as VizzlyComponents.Version),
savedAt: savedAt,
},
});
};
export const setTitle = (

@@ -77,3 +91,7 @@ state: State,

// does not clear the results and queries from the state.
export const setStyleProps = (state: State, setState: SetStateCallback, props: VizzlyPuppet.Component.Props) => {
export const setStyleProps = (
state: State,
setState: SetStateCallback,
props: VizzlyPuppet.Component.Props
) => {
setState({

@@ -86,3 +104,3 @@ ...state,

});
}
};

@@ -89,0 +107,0 @@ export const setResults = (

@@ -24,2 +24,3 @@ import { VizzlyPuppet } from '@vizzly/puppet';

setStyleProps: (styleProps: ComponentProps) => void;
setSavedAt: (savedAt: string) => void;
}

@@ -26,0 +27,0 @@

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 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