@stordco/msw-chakra-toolbar
Advanced tools
Comparing version 0.1.1 to 0.1.2
@@ -35,3 +35,3 @@ import * as React from 'react'; | ||
*/ | ||
export declare const MSWToolbar: ({ children, isEnabled, apiUrl, actions, worker, }: Props) => JSX.Element; | ||
export declare const MSWToolbar: ({ children, isEnabled, apiUrl, actions, worker, }: Props) => JSX.Element | null; | ||
export {}; |
@@ -925,3 +925,3 @@ 'use strict'; | ||
if (!isEnabled || !worker) return React.createElement(React.Fragment, null, children); | ||
return React.createElement(react.ChakraProvider, null, React.createElement("div", null, isReady && React.createElement("div", null, React.createElement(react.Stack, { | ||
return isReady ? React.createElement(React.Fragment, null, React.createElement(react.ChakraProvider, null, React.createElement(react.Stack, { | ||
direction: ['column', 'column', 'row'], | ||
@@ -965,3 +965,3 @@ spacing: 8, | ||
w: "100px" | ||
}, React.createElement(react.NumberInputField, null))), React.createElement(react.Spacer, null), actions ? actions : null), React.createElement("div", null, children)))); | ||
}, React.createElement(react.NumberInputField, null))), React.createElement(react.Spacer, null), actions ? actions : null)), children) : null; | ||
}; | ||
@@ -968,0 +968,0 @@ |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react"),e=require("msw"),r=require("@chakra-ui/react");function n(t,e,r,n,o,a,i){try{var c=t[a](i),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}var o,a=(function(t){var e=function(t){var e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",a=n.asyncIterator||"@@asyncIterator",i=n.toStringTag||"@@toStringTag";function c(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var o=Object.create((e&&e.prototype instanceof f?e:f).prototype),a=new S(n||[]);return o._invoke=function(t,e,r){var n="suspendedStart";return function(o,a){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw a;return{value:void 0,done:!0}}for(r.method=o,r.arg=a;;){var i=r.delegate;if(i){var c=E(i,r);if(c){if(c===s)continue;return c}}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 u=l(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===s)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(t,r,a),o}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var s={};function f(){}function h(){}function p(){}var d={};c(d,o,(function(){return this}));var v=Object.getPrototypeOf,m=v&&v(v(k([])));m&&m!==e&&r.call(m,o)&&(d=m);var y=p.prototype=f.prototype=Object.create(d);function g(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function w(t,e){var n;this._invoke=function(o,a){function i(){return new e((function(n,i){!function n(o,a,i,c){var u=l(t[o],t,a);if("throw"!==u.type){var s=u.arg,f=s.value;return f&&"object"==typeof f&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,i,c)}),(function(t){n("throw",t,i,c)})):e.resolve(f).then((function(t){s.value=t,i(s)}),(function(t){return n("throw",t,i,c)}))}c(u.arg)}(o,a,n,i)}))}return n=n?n.then(i,i):i()}}function E(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,E(t,e),"throw"===e.method))return s;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return s}var n=l(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,s;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,s):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,s)}function b(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 x(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function S(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(b,this),this.reset(!0)}function k(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,a=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 a.next=a}}return{next:L}}function L(){return{value:void 0,done:!0}}return h.prototype=p,c(y,"constructor",p),c(p,"constructor",h),h.displayName=c(p,i,"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,p):(t.__proto__=p,c(t,i,"GeneratorFunction")),t.prototype=Object.create(y),t},t.awrap=function(t){return{__await:t}},g(w.prototype),c(w.prototype,a,(function(){return this})),t.AsyncIterator=w,t.async=function(e,r,n,o,a){void 0===a&&(a=Promise);var i=new w(u(e,r,n,o),a);return t.isGeneratorFunction(r)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},g(y),c(y,i,"Generator"),c(y,o,(function(){return this})),c(y,"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=k,S.prototype={constructor:S,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(x),!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 i.type="throw",i.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 a=this.tryEntries[o],i=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var c=r.call(a,"catchLoc"),u=r.call(a,"finallyLoc");if(c&&u){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.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 a=o;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=t,i.arg=e,a?(this.method="next",this.next=a.finallyLoc,s):this.complete(i)},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),s},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),x(r),s}},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;x(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:k(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),s}},t}(t.exports);try{regeneratorRuntime=e}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=e:Function("r","regeneratorRuntime = r")(e)}}(o={exports:{}}),o.exports);exports.MSWToolbar=function(o){var i,c,u,l=o.children,s=void 0===l?t.createElement("div",null):l,f=o.isEnabled,h=void 0!==f&&f,p=o.apiUrl,d=void 0===p?"":p,v=o.actions,m=o.worker;(h&&!m||h&&m&&!m.start)&&console.warn("Unable to load MSWToolbar due to the worker being undefined. Please pass in a worker instance from setupWorker(...handlers).");var y=t.useRef(),g=t.useState(!h),w=g[0],E=g[1],b=t.useState(null!=(i=localStorage.getItem("mswWorkerMode"))?i:"normal"),x=b[0],S=b[1],k=localStorage.getItem("mswWorkerStatus"),L=t.useState("enabled"===k),_=L[0],j=L[1],O=r.usePrevious(_),P=void 0!==O&&_!==O,T=t.useState(null!=(c=null==(u=localStorage)?void 0:u.getItem("mswDelay"))?c:75),I=T[0],N=T[1];return t.useEffect((function(){m&&h&&!y.current&&function(){var t,e=(t=a.mark((function t(){return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:_&&m.start(),y.current=m,E(!0);case 3:case"end":return t.stop()}}),t)})),function(){var e=this,r=arguments;return new Promise((function(o,a){var i=t.apply(e,r);function c(t){n(i,o,a,c,u,"next",t)}function u(t){n(i,o,a,c,u,"throw",t)}c(void 0)}))});return function(){return e.apply(this,arguments)}}()()}),[_,h,m]),t.useEffect((function(){y.current&&P&&(y.current[_?"start":"stop"](),localStorage.setItem("mswWorkerStatus",_?"enabled":"disabled"))}),[_,P]),t.useEffect((function(){var t,r;switch(localStorage.setItem("mswWorkerMode",x),x){case"normal":return void(null==(t=y.current)||t.resetHandlers());case"error":return void(null==(r=y.current)||r.use.apply(r,["get","post","put","patch","delete"].map((function(t){return e.rest[t](d+"/*",(function(t,e,r){return e.networkError("Fake error")}))}))));default:return}}),[x,w,d]),t.useEffect((function(){var t;null==(t=localStorage)||t.setItem("mswDelay",String(I))}),[I]),h&&m?t.createElement(r.ChakraProvider,null,t.createElement("div",null,w&&t.createElement("div",null,t.createElement(r.Stack,{direction:["column","column","row"],spacing:8,p:2,bg:"blue.100"},t.createElement(r.HStack,null,t.createElement(r.Text,{fontWeight:"bold"},"Mocks:"),t.createElement(r.Switch,{onChange:function(){return j((function(t){return!t}))},isChecked:_,size:"lg"})),t.createElement(r.HStack,null,t.createElement(r.Text,{fontWeight:"bold"},"Mode:"),t.createElement(r.Select,{value:x,onChange:function(t){return S(t.target.value)},w:"150px",bg:"white"},["normal","error"].map((function(e){return t.createElement("option",{value:e,key:e},(r=e).length?r.replace(r[0],r[0].toUpperCase()):"");var r})))),t.createElement(r.HStack,null,t.createElement(r.Text,{fontWeight:"bold"},"Delay (ms):"),t.createElement(r.NumberInput,{onChange:function(t){return N(Number(t))},value:I,bg:"white",w:"100px"},t.createElement(r.NumberInputField,null))),t.createElement(r.Spacer,null),v||null),t.createElement("div",null,s)))):t.createElement(t.Fragment,null,s)}; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react"),e=require("msw"),r=require("@chakra-ui/react");function n(t,e,r,n,o,a,i){try{var c=t[a](i),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}var o,a=(function(t){var e=function(t){var e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",a=n.asyncIterator||"@@asyncIterator",i=n.toStringTag||"@@toStringTag";function c(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var o=Object.create((e&&e.prototype instanceof f?e:f).prototype),a=new S(n||[]);return o._invoke=function(t,e,r){var n="suspendedStart";return function(o,a){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw a;return{value:void 0,done:!0}}for(r.method=o,r.arg=a;;){var i=r.delegate;if(i){var c=E(i,r);if(c){if(c===s)continue;return c}}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 u=l(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===s)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(t,r,a),o}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var s={};function f(){}function h(){}function p(){}var d={};c(d,o,(function(){return this}));var v=Object.getPrototypeOf,m=v&&v(v(k([])));m&&m!==e&&r.call(m,o)&&(d=m);var y=p.prototype=f.prototype=Object.create(d);function g(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function w(t,e){var n;this._invoke=function(o,a){function i(){return new e((function(n,i){!function n(o,a,i,c){var u=l(t[o],t,a);if("throw"!==u.type){var s=u.arg,f=s.value;return f&&"object"==typeof f&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,i,c)}),(function(t){n("throw",t,i,c)})):e.resolve(f).then((function(t){s.value=t,i(s)}),(function(t){return n("throw",t,i,c)}))}c(u.arg)}(o,a,n,i)}))}return n=n?n.then(i,i):i()}}function E(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,E(t,e),"throw"===e.method))return s;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return s}var n=l(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,s;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,s):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,s)}function b(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 x(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function S(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(b,this),this.reset(!0)}function k(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,a=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 a.next=a}}return{next:L}}function L(){return{value:void 0,done:!0}}return h.prototype=p,c(y,"constructor",p),c(p,"constructor",h),h.displayName=c(p,i,"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,p):(t.__proto__=p,c(t,i,"GeneratorFunction")),t.prototype=Object.create(y),t},t.awrap=function(t){return{__await:t}},g(w.prototype),c(w.prototype,a,(function(){return this})),t.AsyncIterator=w,t.async=function(e,r,n,o,a){void 0===a&&(a=Promise);var i=new w(u(e,r,n,o),a);return t.isGeneratorFunction(r)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},g(y),c(y,i,"Generator"),c(y,o,(function(){return this})),c(y,"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=k,S.prototype={constructor:S,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(x),!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 i.type="throw",i.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 a=this.tryEntries[o],i=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var c=r.call(a,"catchLoc"),u=r.call(a,"finallyLoc");if(c&&u){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.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 a=o;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=t,i.arg=e,a?(this.method="next",this.next=a.finallyLoc,s):this.complete(i)},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),s},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),x(r),s}},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;x(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:k(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),s}},t}(t.exports);try{regeneratorRuntime=e}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=e:Function("r","regeneratorRuntime = r")(e)}}(o={exports:{}}),o.exports);exports.MSWToolbar=function(o){var i,c,u,l=o.children,s=void 0===l?t.createElement("div",null):l,f=o.isEnabled,h=void 0!==f&&f,p=o.apiUrl,d=void 0===p?"":p,v=o.actions,m=o.worker;(h&&!m||h&&m&&!m.start)&&console.warn("Unable to load MSWToolbar due to the worker being undefined. Please pass in a worker instance from setupWorker(...handlers).");var y=t.useRef(),g=t.useState(!h),w=g[0],E=g[1],b=t.useState(null!=(i=localStorage.getItem("mswWorkerMode"))?i:"normal"),x=b[0],S=b[1],k=localStorage.getItem("mswWorkerStatus"),L=t.useState("enabled"===k),_=L[0],j=L[1],O=r.usePrevious(_),P=void 0!==O&&_!==O,T=t.useState(null!=(c=null==(u=localStorage)?void 0:u.getItem("mswDelay"))?c:75),I=T[0],N=T[1];return t.useEffect((function(){m&&h&&!y.current&&function(){var t,e=(t=a.mark((function t(){return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:_&&m.start(),y.current=m,E(!0);case 3:case"end":return t.stop()}}),t)})),function(){var e=this,r=arguments;return new Promise((function(o,a){var i=t.apply(e,r);function c(t){n(i,o,a,c,u,"next",t)}function u(t){n(i,o,a,c,u,"throw",t)}c(void 0)}))});return function(){return e.apply(this,arguments)}}()()}),[_,h,m]),t.useEffect((function(){y.current&&P&&(y.current[_?"start":"stop"](),localStorage.setItem("mswWorkerStatus",_?"enabled":"disabled"))}),[_,P]),t.useEffect((function(){var t,r;switch(localStorage.setItem("mswWorkerMode",x),x){case"normal":return void(null==(t=y.current)||t.resetHandlers());case"error":return void(null==(r=y.current)||r.use.apply(r,["get","post","put","patch","delete"].map((function(t){return e.rest[t](d+"/*",(function(t,e,r){return e.networkError("Fake error")}))}))));default:return}}),[x,w,d]),t.useEffect((function(){var t;null==(t=localStorage)||t.setItem("mswDelay",String(I))}),[I]),h&&m?w?t.createElement(t.Fragment,null,t.createElement(r.ChakraProvider,null,t.createElement(r.Stack,{direction:["column","column","row"],spacing:8,p:2,bg:"blue.100"},t.createElement(r.HStack,null,t.createElement(r.Text,{fontWeight:"bold"},"Mocks:"),t.createElement(r.Switch,{onChange:function(){return j((function(t){return!t}))},isChecked:_,size:"lg"})),t.createElement(r.HStack,null,t.createElement(r.Text,{fontWeight:"bold"},"Mode:"),t.createElement(r.Select,{value:x,onChange:function(t){return S(t.target.value)},w:"150px",bg:"white"},["normal","error"].map((function(e){return t.createElement("option",{value:e,key:e},(r=e).length?r.replace(r[0],r[0].toUpperCase()):"");var r})))),t.createElement(r.HStack,null,t.createElement(r.Text,{fontWeight:"bold"},"Delay (ms):"),t.createElement(r.NumberInput,{onChange:function(t){return N(Number(t))},value:I,bg:"white",w:"100px"},t.createElement(r.NumberInputField,null))),t.createElement(r.Spacer,null),v||null)),s):null:t.createElement(t.Fragment,null,s)}; | ||
//# sourceMappingURL=msw-chakra-toolbar.cjs.production.min.js.map |
@@ -921,3 +921,3 @@ import { createElement, useRef, useState, useEffect, Fragment } from 'react'; | ||
if (!isEnabled || !worker) return createElement(Fragment, null, children); | ||
return createElement(ChakraProvider, null, createElement("div", null, isReady && createElement("div", null, createElement(Stack, { | ||
return isReady ? createElement(Fragment, null, createElement(ChakraProvider, null, createElement(Stack, { | ||
direction: ['column', 'column', 'row'], | ||
@@ -961,3 +961,3 @@ spacing: 8, | ||
w: "100px" | ||
}, createElement(NumberInputField, null))), createElement(Spacer, null), actions ? actions : null), createElement("div", null, children)))); | ||
}, createElement(NumberInputField, null))), createElement(Spacer, null), actions ? actions : null)), children) : null; | ||
}; | ||
@@ -964,0 +964,0 @@ |
{ | ||
"name": "@stordco/msw-chakra-toolbar", | ||
"author": "STORD", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "homepage": "https://github.com/stordco/msw-chakra-toolbar", |
@@ -6,3 +6,29 @@ # MSW Toolbar | ||
### Requirements | ||
- [msw](https://github.com/mswjs/msw) | ||
- [chakra-ui](https://github.com/chakra-ui/chakra-ui) | ||
### Usage | ||
There are two primary ways to use this component: | ||
1. As a wrapper around your entire app | ||
1. When you structure things like the below, you guarantee that _all requests_ will be intercepted because `children` will not be rendered until the worker has successfully started. | ||
```ts | ||
<MSWToolbar {...props}> | ||
<YourApp /> | ||
</MSWToolbar> | ||
``` | ||
2. As a regular component in the tree | ||
1. When you do this, all requests _should be intercepted_, but it's not guaranteed because there can be timing issues with the service worker registration. | ||
```ts | ||
<YourApp> | ||
<MSWToolbar {...props} /> | ||
<Header /> | ||
<Content /> | ||
<Footer /> | ||
</YourApp> | ||
``` |
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
34
240924
1907