msw-dev-tool 1.1.6 → 1.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/esm/index.js CHANGED
@@ -28109,41 +28109,35 @@ const RequestPreview = ({ url, paramValues, headers = {}, searchParams = {}, })
28109
28109
  } }, JSON.stringify(response, null, 2)))))));
28110
28110
  };
28111
28111
 
28112
+ /**
28113
+ * - It uses `zustand` global state.
28114
+ * - remounting of the inner component that uses local states.
28115
+ * - To force a component to be remounted, use `key` prop.
28116
+ */
28112
28117
  const HandlerDebugger = () => {
28113
- var _a;
28114
28118
  const { currentHandler: handler } = useUiControlStore();
28115
- const path = (_a = handler === null || handler === void 0 ? void 0 : handler.info.path) !== null && _a !== void 0 ? _a : "";
28119
+ const key = `${handler === null || handler === void 0 ? void 0 : handler.info.path}-${handler === null || handler === void 0 ? void 0 : handler.info.method}`;
28120
+ return (React__default.createElement(Container, null, handler ? (React__default.createElement(_HandlerDebugger, { handler: handler, key: key })) : (React__default.createElement(p$b, null, "Select a handler from the table to debug"))));
28121
+ };
28122
+ const _HandlerDebugger = ({ handler }) => {
28123
+ const path = handler === null || handler === void 0 ? void 0 : handler.info.path;
28116
28124
  const url = new URL(String(path), location.href);
28117
28125
  const { params } = matchRequestUrl(url, path, url.origin);
28118
- const [paramValues, setParamValues] = useState(undefined);
28126
+ const [paramValues, setParamValues] = useState(params
28127
+ ? Object.keys(params).reduce((acc, key) => ({
28128
+ ...acc,
28129
+ [key]: "",
28130
+ }), {})
28131
+ : undefined);
28119
28132
  const [headers, setHeaders] = useState({});
28120
28133
  const [searchParams, setSearchParams] = useState({});
28121
- /**
28122
- * Initialize state to clear previous handler data
28123
- */
28124
- useEffect(() => {
28125
- if (params) {
28126
- setParamValues(Object.keys(params).reduce((acc, key) => ({
28127
- ...acc,
28128
- [key]: "",
28129
- }), {}));
28130
- }
28131
- else {
28132
- setParamValues(undefined);
28133
- }
28134
- setHeaders({});
28135
- setSearchParams({});
28136
- }, [handler]);
28137
28134
  const handleParamChange = (key, value) => {
28138
28135
  setParamValues((prev) => ({
28139
28136
  ...prev,
28140
28137
  [key]: value,
28141
28138
  }));
28142
28139
  };
28143
- if (!handler)
28144
- return (React__default.createElement(Container, null,
28145
- React__default.createElement(p$b, null, "Select a handler from the table to debug")));
28146
- return (React__default.createElement(Container, null,
28140
+ return (React__default.createElement(React__default.Fragment, null,
28147
28141
  React__default.createElement(p$b, { className: "msw-dt-sub-text", style: { overflowX: "scroll" } }, url.toString()),
28148
28142
  React__default.createElement(PathParamSetter, { paramValues: paramValues, onParamChange: handleParamChange }),
28149
28143
  React__default.createElement(KeyValueInputList, { items: searchParams, setItems: setSearchParams, title: "Search Params" }),
@@ -28188,6 +28182,7 @@ const MSWDevTool = () => {
28188
28182
  borderRadius: "50%",
28189
28183
  width: "3.5rem",
28190
28184
  height: "3.5rem",
28185
+ margin: "1rem",
28191
28186
  } }, "M")),
28192
28187
  React__default.createElement(Drawer.Portal, null,
28193
28188
  React__default.createElement(ThemeProvider, null,