msw-dev-tool 1.0.16 → 1.0.18

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.
Files changed (51) hide show
  1. package/dist/cjs/_virtual/_commonjsHelpers.js +6 -0
  2. package/dist/cjs/_virtual/_commonjsHelpers.js.map +1 -0
  3. package/dist/cjs/_virtual/lodash.js +6 -0
  4. package/dist/cjs/_virtual/lodash.js.map +1 -0
  5. package/dist/cjs/index.js +0 -1
  6. package/dist/cjs/index.js.map +1 -1
  7. package/dist/cjs/lib/handlerStore.js +29 -30
  8. package/dist/cjs/lib/handlerStore.js.map +1 -1
  9. package/dist/cjs/lib/util.js +15 -16
  10. package/dist/cjs/lib/util.js.map +1 -1
  11. package/dist/cjs/msw-dev-tool.css +1 -1
  12. package/dist/cjs/node_modules/@tanstack/react-table/build/lib/index.js +137 -0
  13. package/dist/cjs/node_modules/@tanstack/react-table/build/lib/index.js.map +1 -0
  14. package/dist/cjs/node_modules/@tanstack/table-core/build/lib/index.js +3012 -0
  15. package/dist/cjs/node_modules/@tanstack/table-core/build/lib/index.js.map +1 -0
  16. package/dist/cjs/node_modules/lodash/lodash.js +17209 -0
  17. package/dist/cjs/node_modules/lodash/lodash.js.map +1 -0
  18. package/dist/cjs/ui/DevToolContent/HttpControl.js +35 -17
  19. package/dist/cjs/ui/DevToolContent/HttpControl.js.map +1 -1
  20. package/dist/esm/_virtual/_commonjsHelpers.js +4 -0
  21. package/dist/esm/_virtual/_commonjsHelpers.js.map +1 -0
  22. package/dist/esm/_virtual/lodash.js +4 -0
  23. package/dist/esm/_virtual/lodash.js.map +1 -0
  24. package/dist/esm/index.js +1 -1
  25. package/dist/esm/lib/handlerStore.js +30 -31
  26. package/dist/esm/lib/handlerStore.js.map +1 -1
  27. package/dist/esm/lib/util.js +15 -16
  28. package/dist/esm/lib/util.js.map +1 -1
  29. package/dist/esm/msw-dev-tool.css +1 -1
  30. package/dist/esm/node_modules/@tanstack/react-table/build/lib/index.js +75 -0
  31. package/dist/esm/node_modules/@tanstack/react-table/build/lib/index.js.map +1 -0
  32. package/dist/esm/node_modules/@tanstack/table-core/build/lib/index.js +2970 -0
  33. package/dist/esm/node_modules/@tanstack/table-core/build/lib/index.js.map +1 -0
  34. package/dist/esm/node_modules/lodash/lodash.js +17207 -0
  35. package/dist/esm/node_modules/lodash/lodash.js.map +1 -0
  36. package/dist/esm/ui/DevToolContent/DevToolContentContainer.js +6 -6
  37. package/dist/esm/ui/DevToolContent/DevToolContentContainer.js.map +1 -1
  38. package/dist/esm/ui/DevToolContent/HttpControl.js +37 -19
  39. package/dist/esm/ui/DevToolContent/HttpControl.js.map +1 -1
  40. package/dist/esm/ui/MSWDevTool.js +4 -4
  41. package/dist/esm/ui/MSWDevTool.js.map +1 -1
  42. package/dist/types/index.d.ts +8 -34
  43. package/package.json +5 -2
  44. package/dist/cjs/node_modules/immer/dist/immer.js +0 -717
  45. package/dist/cjs/node_modules/immer/dist/immer.js.map +0 -1
  46. package/dist/cjs/utils/handlerMap.js +0 -13
  47. package/dist/cjs/utils/handlerMap.js.map +0 -1
  48. package/dist/esm/node_modules/immer/dist/immer.js +0 -708
  49. package/dist/esm/node_modules/immer/dist/immer.js.map +0 -1
  50. package/dist/esm/utils/handlerMap.js +0 -11
  51. package/dist/esm/utils/handlerMap.js.map +0 -1
@@ -1,27 +1,45 @@
1
1
  'use strict';
2
2
 
3
3
  var React = require('react');
4
+ var index = require('../../node_modules/@tanstack/react-table/build/lib/index.js');
4
5
  var handlerStore = require('../../lib/handlerStore.js');
5
- var handlerMap = require('../../utils/handlerMap.js');
6
- var handler = require('../../const/handler.js');
6
+ var index$1 = require('../../node_modules/@tanstack/table-core/build/lib/index.js');
7
7
 
8
8
  const HttpControl = () => {
9
- const { handlerMap: handlerMap$1 } = handlerStore.useHandlerStore();
10
- return (React.createElement("div", null, handlerMap.flatHandlerMap(handlerMap$1).map((flat) => {
11
- const { url, method } = flat;
12
- if (url === handler.dummyUrl) {
13
- return React.createElement(React.Fragment, null);
14
- }
15
- return (React.createElement(HttpControlElement, { key: `${url}-${method}`, url: url, method: method }));
16
- })));
17
- };
18
- const HttpControlElement = ({ url, method, }) => {
19
- const { getIsChecked, toggleIsChecked } = handlerStore.useHandlerStore();
9
+ const { flattenHandlers, handlerRowSelection, handleHandlerRowSelectionChange } = handlerStore.useHandlerStore();
10
+ const columnHelper = index$1.createColumnHelper();
11
+ const columns = React.useMemo(() => {
12
+ return [
13
+ columnHelper.accessor("enabled", {
14
+ header: ({ table }) => (React.createElement("input", { type: "checkbox", checked: table.getIsAllRowsSelected(), onChange: (e) => table.toggleAllRowsSelected(e.target.checked) })),
15
+ cell: ({ row }) => (React.createElement("input", { type: "checkbox", checked: row.getIsSelected(), onChange: (e) => row.toggleSelected(e.target.checked) })),
16
+ }),
17
+ columnHelper.accessor("path", {
18
+ header: "End point",
19
+ }),
20
+ columnHelper.accessor("method", {
21
+ header: "Method",
22
+ cell: ({ row }) => (React.createElement("div", { className: "msw-dev-tool-center" }, row.original.enabled)),
23
+ }),
24
+ ];
25
+ }, []);
26
+ const table = index.useReactTable({
27
+ columns,
28
+ data: flattenHandlers,
29
+ getCoreRowModel: index$1.getCoreRowModel(),
30
+ state: {
31
+ rowSelection: handlerRowSelection,
32
+ },
33
+ onRowSelectionChange: handleHandlerRowSelectionChange,
34
+ getRowId: (row) => row.id,
35
+ enableRowSelection: true,
36
+ });
20
37
  return (React.createElement("div", null,
21
- React.createElement("p", null, url),
22
- React.createElement("label", null,
23
- method,
24
- React.createElement("input", { type: "checkbox", checked: getIsChecked(url, method), onChange: () => toggleIsChecked(url, method) }))));
38
+ React.createElement("table", null,
39
+ React.createElement("thead", null, table.getHeaderGroups().map((headerGroup) => (React.createElement("tr", { key: headerGroup.id }, headerGroup.headers.map((header) => (React.createElement("th", { key: header.id }, header.isPlaceholder
40
+ ? null
41
+ : index.flexRender(header.column.columnDef.header, header.getContext())))))))),
42
+ React.createElement("tbody", null, table.getRowModel().rows.map((row) => (React.createElement("tr", { key: row.id }, row.getVisibleCells().map((cell) => (React.createElement("td", { key: cell.id }, index.flexRender(cell.column.columnDef.cell, cell.getContext())))))))))));
25
43
  };
26
44
 
27
45
  exports.HttpControl = HttpControl;
@@ -1 +1 @@
1
- {"version":3,"file":"HttpControl.js","sources":["../../../../src/ui/DevToolContent/HttpControl.tsx"],"sourcesContent":["import React from \"react\";\nimport { useHandlerStore } from \"../../lib\";\nimport { flatHandlerMap } from \"../../utils/handlerMap\";\nimport { dummyUrl } from \"../../const/handler\";\n\nexport const HttpControl = () => {\n const { handlerMap } = useHandlerStore();\n return (\n <div>\n {flatHandlerMap(handlerMap).map((flat) => {\n const { url, method } = flat;\n if (url === dummyUrl) {\n return <></>;\n }\n return (\n <HttpControlElement\n key={`${url}-${method}`}\n url={url}\n method={method}\n />\n );\n })}\n </div>\n );\n};\n\nconst HttpControlElement = ({\n url,\n method,\n}: {\n url: string;\n method: string;\n}) => {\n const { getIsChecked, toggleIsChecked } = useHandlerStore();\n return (\n <div>\n <p>{url}</p>\n <label>\n {method}\n <input\n type=\"checkbox\"\n checked={getIsChecked(url, method)}\n onChange={() => toggleIsChecked(url, method)}\n />\n </label>\n </div>\n );\n};\n"],"names":["handlerMap","useHandlerStore","flatHandlerMap","dummyUrl"],"mappings":";;;;;;;AAKO,MAAM,WAAW,GAAG,MAAK;AAC9B,IAAA,MAAM,cAAEA,YAAU,EAAE,GAAGC,4BAAe,EAAE,CAAC;AACzC,IAAA,QACE,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA,IAAA,EACGC,yBAAc,CAACF,YAAU,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,KAAI;AACvC,QAAA,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;AAC7B,QAAA,IAAI,GAAG,KAAKG,gBAAQ,EAAE;AACpB,YAAA,OAAO,yCAAK,CAAC;SACd;QACD,QACE,oBAAC,kBAAkB,EAAA,EACjB,GAAG,EAAE,CAAA,EAAG,GAAG,CAAI,CAAA,EAAA,MAAM,EAAE,EACvB,GAAG,EAAE,GAAG,EACR,MAAM,EAAE,MAAM,EACd,CAAA,EACF;KACH,CAAC,CACE,EACN;AACJ,EAAE;AAEF,MAAM,kBAAkB,GAAG,CAAC,EAC1B,GAAG,EACH,MAAM,GAIP,KAAI;IACH,MAAM,EAAE,YAAY,EAAE,eAAe,EAAE,GAAGF,4BAAe,EAAE,CAAC;AAC5D,IAAA,QACE,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA,IAAA;AACE,QAAA,KAAA,CAAA,aAAA,CAAA,GAAA,EAAA,IAAA,EAAI,GAAG,CAAK;AACZ,QAAA,KAAA,CAAA,aAAA,CAAA,OAAA,EAAA,IAAA;YACG,MAAM;AACP,YAAA,KAAA,CAAA,aAAA,CAAA,OAAA,EAAA,EACE,IAAI,EAAC,UAAU,EACf,OAAO,EAAE,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,EAClC,QAAQ,EAAE,MAAM,eAAe,CAAC,GAAG,EAAE,MAAM,CAAC,EAC5C,CAAA,CACI,CACJ,EACN;AACJ,CAAC;;;;"}
1
+ {"version":3,"file":"HttpControl.js","sources":["../../../../src/ui/DevToolContent/HttpControl.tsx"],"sourcesContent":["import React, { useMemo } from \"react\";\nimport { dummyUrl } from \"../../const/handler\";\nimport {\n ColumnDef,\n createColumnHelper,\n flexRender,\n getCoreRowModel,\n useReactTable,\n} from \"@tanstack/react-table\";\nimport { useHandlerStore } from \"../../lib/handlerStore\";\nimport { FlattenHandler } from \"../../lib\";\n\nexport const HttpControl = () => {\n const { flattenHandlers,handlerRowSelection,handleHandlerRowSelectionChange } = useHandlerStore();\n\n const columnHelper = createColumnHelper<FlattenHandler>();\n const columns: ColumnDef<FlattenHandler, any>[] = useMemo(() => {\n return [\n columnHelper.accessor(\"enabled\", {\n header: ({ table }) => (\n <input\n type=\"checkbox\"\n checked={table.getIsAllRowsSelected()}\n onChange={(e) => table.toggleAllRowsSelected(e.target.checked)}\n />\n ),\n cell: ({ row }) => (\n <input\n type=\"checkbox\"\n checked={row.getIsSelected()}\n onChange={(e) => row.toggleSelected(e.target.checked)}\n />\n ),\n }),\n columnHelper.accessor(\"path\", {\n header: \"End point\",\n }),\n columnHelper.accessor(\"method\", {\n header: \"Method\",\n cell: ({ row }) => (\n <div className=\"msw-dev-tool-center\">{row.original.enabled}</div>\n ),\n }),\n ];\n }, []);\n\n const table = useReactTable({\n columns,\n data:flattenHandlers,\n getCoreRowModel: getCoreRowModel(),\n state: {\n rowSelection:handlerRowSelection,\n },\n onRowSelectionChange: handleHandlerRowSelectionChange,\n getRowId:(row)=>row.id,\n enableRowSelection: true,\n });\n\n return (\n <div>\n <table>\n <thead>\n {table.getHeaderGroups().map((headerGroup) => (\n <tr key={headerGroup.id}>\n {headerGroup.headers.map((header) => (\n <th key={header.id}>\n {header.isPlaceholder\n ? null\n : flexRender(\n header.column.columnDef.header,\n header.getContext()\n )}\n </th>\n ))}\n </tr>\n ))}\n </thead>\n <tbody>\n {table.getRowModel().rows.map((row) => (\n <tr key={row.id}>\n {row.getVisibleCells().map((cell) => (\n <td key={cell.id}>\n {flexRender(cell.column.columnDef.cell, cell.getContext())}\n </td>\n ))}\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n );\n};\n"],"names":["useHandlerStore","createColumnHelper","useMemo","useReactTable","getCoreRowModel","flexRender"],"mappings":";;;;;;;AAYO,MAAM,WAAW,GAAG,MAAK;IAC9B,MAAM,EAAE,eAAe,EAAC,mBAAmB,EAAC,+BAA+B,EAAE,GAAGA,4BAAe,EAAE,CAAC;AAElG,IAAA,MAAM,YAAY,GAAGC,0BAAkB,EAAkB,CAAC;AAC1D,IAAA,MAAM,OAAO,GAAqCC,aAAO,CAAC,MAAK;QAC7D,OAAO;AACL,YAAA,YAAY,CAAC,QAAQ,CAAC,SAAS,EAAE;AAC/B,gBAAA,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,MAChB,KAAA,CAAA,aAAA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EAAA,IAAA;AACE,QAAA,KAAA,CAAA,aAAA,CAAA,OAAA,EAAA,IAAA;AACE,YAAA,KAAA,CAAA,aAAA,CAAA,OAAA,EAAA,IAAA,EACG,KAAK,CAAC,eAAe,EAAE,CAAC,GAAG,CAAC,CAAC,WAAW,MACvC,KAAA,CAAA,aAAA,CAAA,IAAA,EAAA,EAAI,GAAG,EAAE,WAAW,CAAC,EAAE,EAAA,EACpB,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,MAC9B,KAAI,CAAA,aAAA,CAAA,IAAA,EAAA,EAAA,GAAG,EAAE,MAAM,CAAC,EAAE,EACf,EAAA,MAAM,CAAC,aAAa;AACnB,kBAAE,IAAI;kBACJC,gBAAU,CACR,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,EAC9B,MAAM,CAAC,UAAU,EAAE,CACpB,CACF,CACN,CAAC,CACC,CACN,CAAC,CACI;AACR,YAAA,KAAA,CAAA,aAAA,CAAA,OAAA,EAAA,IAAA,EACG,KAAK,CAAC,WAAW,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,MAChC,KAAI,CAAA,aAAA,CAAA,IAAA,EAAA,EAAA,GAAG,EAAE,GAAG,CAAC,EAAE,IACZ,GAAG,CAAC,eAAe,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,MAC9B,KAAI,CAAA,aAAA,CAAA,IAAA,EAAA,EAAA,GAAG,EAAE,IAAI,CAAC,EAAE,EAAA,EACbA,gBAAU,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC,CACvD,CACN,CAAC,CACC,CACN,CAAC,CACI,CACF,CACJ,EACN;AACJ;;;;"}
@@ -0,0 +1,4 @@
1
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
2
+
3
+ export { commonjsGlobal };
4
+ //# sourceMappingURL=_commonjsHelpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_commonjsHelpers.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
@@ -0,0 +1,4 @@
1
+ var lodash = {exports: {}};
2
+
3
+ export { lodash as __module };
4
+ //# sourceMappingURL=lodash.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lodash.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
package/dist/esm/index.js CHANGED
@@ -1,3 +1,3 @@
1
1
  export { MSWDevTool } from './ui/MSWDevTool.js';
2
- export { initMSWDevTool, useHandlerStore } from './lib/handlerStore.js';
2
+ export { initMSWDevTool } from './lib/handlerStore.js';
3
3
  //# sourceMappingURL=index.js.map
@@ -1,44 +1,44 @@
1
1
  import { create } from 'zustand';
2
- import { produce } from '../node_modules/immer/dist/immer.js';
3
- import { convertHandlers, flatHandlerMap } from './util.js';
2
+ import { convertHandlers } from './util.js';
4
3
  import { dummyHandler } from '../const/handler.js';
4
+ import { l as lodashExports } from '../node_modules/lodash/lodash.js';
5
5
 
6
6
  const useHandlerStore = create((set, get) => ({
7
- handlerMap: {},
7
+ flattenHandlers: [],
8
8
  worker: null,
9
9
  restHandlers: [],
10
+ handlerRowSelection: {},
10
11
  initMSWDevTool: (_worker) => {
11
12
  const worker = _worker;
12
13
  set({ worker });
13
14
  const handlers = worker.listHandlers();
14
- const { handlerMap, unsupportedHandlers } = convertHandlers(handlers);
15
- set({ handlerMap });
15
+ const { flattenHandlers, unsupportedHandlers } = convertHandlers(handlers);
16
+ set({ flattenHandlers });
17
+ set({
18
+ handlerRowSelection: flattenHandlers.reduce((acc, handler) => {
19
+ acc[handler.id] = handler.enabled;
20
+ return acc;
21
+ }, {}),
22
+ });
16
23
  set({ restHandlers: unsupportedHandlers });
17
24
  return worker;
18
25
  },
19
- setHandlerMap: (handlerMap) => {
20
- set({ handlerMap });
21
- return handlerMap;
22
- },
23
- getIsChecked: (url, method) => { var _a; return (_a = get().handlerMap[url]) === null || _a === void 0 ? void 0 : _a[method].checked; },
24
- setIsChecked: (url, method, isChecked) => {
25
- set(produce((state) => {
26
- if (!state.handlerMap[url]) {
27
- return;
28
- }
29
- state.handlerMap[url][method].checked = isChecked;
30
- }));
31
- get().updateEnableHandlers();
32
- },
33
- toggleIsChecked: (url, method) => {
34
- set(produce((state) => {
35
- var _a;
36
- if (!((_a = state.handlerMap[url]) === null || _a === void 0 ? void 0 : _a[method])) {
37
- return;
38
- }
39
- state.handlerMap[url][method].checked =
40
- !state.handlerMap[url][method].checked;
41
- }));
26
+ handleHandlerRowSelectionChange: (updater) => {
27
+ if (lodashExports.isFunction(updater)) {
28
+ set(({ handlerRowSelection }) => {
29
+ const next = updater(handlerRowSelection);
30
+ const current = get().flattenHandlers.map((handler) => next[handler.id]
31
+ ? { ...handler, enabled: true }
32
+ : { ...handler, enabled: false });
33
+ return { handlerRowSelection: next, flattenHandlers: current };
34
+ });
35
+ }
36
+ else {
37
+ const current = get().flattenHandlers.map((handler) => updater[handler.id]
38
+ ? { ...handler, enabled: true }
39
+ : { ...handler, enabled: false });
40
+ set({ handlerRowSelection: updater, flattenHandlers: current });
41
+ }
42
42
  get().updateEnableHandlers();
43
43
  },
44
44
  getWorker: () => {
@@ -48,9 +48,8 @@ const useHandlerStore = create((set, get) => ({
48
48
  return worker;
49
49
  },
50
50
  getTotalEnableHandlers: () => {
51
- const handlerMapList = flatHandlerMap(get().handlerMap);
52
- const checkedHttpHandlers = handlerMapList
53
- .filter((h) => h.checked)
51
+ const checkedHttpHandlers = get()
52
+ .flattenHandlers.filter((h) => h.enabled)
54
53
  .map((h) => h.handler);
55
54
  const otherProtocolHandlers = get().restHandlers;
56
55
  return [...checkedHttpHandlers, ...otherProtocolHandlers];
@@ -1 +1 @@
1
- {"version":3,"file":"handlerStore.js","sources":["../../../src/lib/handlerStore.ts"],"sourcesContent":["import { SetupWorker } from \"msw/browser\";\nimport { create } from \"zustand\";\nimport { produce } from \"immer\";\nimport { Handler, HandlerMap } from \"./type\";\nimport { convertHandlers, flatHandlerMap } from \"./util\";\nimport { dummyHandler } from \"../const/handler\";\nimport { HttpHandler } from \"msw\";\n\nexport interface HandlerStoreState {\n worker: SetupWorker | null;\n /**\n * HTTP handler map\n */\n handlerMap: HandlerMap;\n /**\n * GraphQL or WebSocketHandler\n *\n * **Currently not supported**\n */\n restHandlers: Handler[];\n initMSWDevTool: (worker: SetupWorker) => SetupWorker;\n setHandlerMap: (handlers: HandlerMap) => HandlerMap;\n getIsChecked: (url: string, method: string) => boolean;\n setIsChecked: (url: string, method: string, isChecked: boolean) => void;\n toggleIsChecked: (url: string, method: string) => void;\n getWorker: () => SetupWorker;\n getTotalEnableHandlers: () => (Handler | HttpHandler)[];\n /**\n * This has to do with `msw` internal workings.\n * If I spread an empty array in `resetHandlers`, it will be replaced by `initialHandler`.\n * Therefore, I proposed the `clear` method, but unfortunately it was not accepted!\n */\n updateEnableHandlers: () => void;\n}\nexport const useHandlerStore = create<HandlerStoreState>((set, get) => ({\n handlerMap: {},\n worker: null,\n restHandlers: [],\n initMSWDevTool: (_worker) => {\n const worker = _worker;\n set({ worker });\n const handlers = worker.listHandlers() as Handler[];\n const { handlerMap, unsupportedHandlers } = convertHandlers(handlers);\n set({ handlerMap });\n set({ restHandlers: unsupportedHandlers });\n return worker;\n },\n setHandlerMap: (handlerMap) => {\n set({ handlerMap });\n return handlerMap;\n },\n getIsChecked: (url, method) => get().handlerMap[url]?.[method].checked,\n setIsChecked: (url, method, isChecked) => {\n set(\n produce<HandlerStoreState>((state) => {\n if (!state.handlerMap[url]) {\n return;\n }\n state.handlerMap[url][method].checked = isChecked;\n })\n );\n get().updateEnableHandlers();\n },\n toggleIsChecked: (url, method) => {\n set(\n produce<HandlerStoreState>((state) => {\n if (!state.handlerMap[url]?.[method]) {\n return;\n }\n state.handlerMap[url][method].checked =\n !state.handlerMap[url][method].checked;\n })\n );\n get().updateEnableHandlers();\n },\n getWorker: () => {\n const worker = get().worker;\n if (!worker) throw new Error(\"Worker is not initialized\");\n return worker;\n },\n getTotalEnableHandlers: () => {\n const handlerMapList = flatHandlerMap(get().handlerMap);\n const checkedHttpHandlers = handlerMapList\n .filter((h) => h.checked)\n .map((h) => h.handler);\n const otherProtocolHandlers = get().restHandlers;\n return [...checkedHttpHandlers, ...otherProtocolHandlers];\n },\n updateEnableHandlers: () => {\n const worker = get().getWorker();\n const totalEnableHandlers = get().getTotalEnableHandlers();\n if (totalEnableHandlers.length === 0) {\n worker.resetHandlers(dummyHandler);\n return;\n }\n\n worker.resetHandlers(...totalEnableHandlers);\n },\n}));\n\nexport const initMSWDevTool = useHandlerStore.getState().initMSWDevTool;\n"],"names":[],"mappings":";;;;;AAkCO,MAAM,eAAe,GAAG,MAAM,CAAoB,CAAC,GAAG,EAAE,GAAG,MAAM;AACtE,IAAA,UAAU,EAAE,EAAE;AACd,IAAA,MAAM,EAAE,IAAI;AACZ,IAAA,YAAY,EAAE,EAAE;AAChB,IAAA,cAAc,EAAE,CAAC,OAAO,KAAI;QAC1B,MAAM,MAAM,GAAG,OAAO,CAAC;AACvB,QAAA,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;AAChB,QAAA,MAAM,QAAQ,GAAG,MAAM,CAAC,YAAY,EAAe,CAAC;QACpD,MAAM,EAAE,UAAU,EAAE,mBAAmB,EAAE,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAC;AACtE,QAAA,GAAG,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC;AACpB,QAAA,GAAG,CAAC,EAAE,YAAY,EAAE,mBAAmB,EAAE,CAAC,CAAC;AAC3C,QAAA,OAAO,MAAM,CAAC;KACf;AACD,IAAA,aAAa,EAAE,CAAC,UAAU,KAAI;AAC5B,QAAA,GAAG,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC;AACpB,QAAA,OAAO,UAAU,CAAC;KACnB;IACD,YAAY,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,EAAA,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AO,MAAM,CAAC;KACf;IACD,sBAAsB,EAAE,MAAK;QAC3B,MAAM,cAAc,GAAG,cAAc,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,CAAC;QACxD,MAAM,mBAAmB,GAAG,cAAc;aACvC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC;aACxB,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC;AACzB,QAAA,MAAM,qBAAqB,GAAG,GAAG,EAAE,CAAC,YAAY,CAAC;AACjD,QAAA,OAAO,CAAC,GAAG,mBAAmB,EAAE,GAAG,qBAAqB,CAAC,CAAC;KAC3D;IACD,oBAAoB,EAAE,MAAK;AACzB,QAAA,MAAM,MAAM,GAAG,GAAG,EAAE,CAAC,SAAS,EAAE,CAAC;AACjC,QAAA,MAAM,mBAAmB,GAAG,GAAG,EAAE,CAAC,sBAAsB,EAAE,CAAC;AAC3D,QAAA,IAAI,mBAAmB,CAAC,MAAM,KAAK,CAAC,EAAE;AACpC,YAAA,MAAM,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC;YACnC,OAAO;SACR;AAED,QAAA,MAAM,CAAC,aAAa,CAAC,GAAG,mBAAmB,CAAC,CAAC;KAC9C;AACF,CAAA,CAAC,EAAE;AAES,MAAA,cAAc,GAAG,eAAe,CAAC,QAAQ,EAAE,CAAC;;;;"}
1
+ {"version":3,"file":"handlerStore.js","sources":["../../../src/lib/handlerStore.ts"],"sourcesContent":["import { SetupWorker } from \"msw/browser\";\nimport { create } from \"zustand\";\nimport { FlattenHandler, Handler } from \"./type\";\nimport { convertHandlers } from \"./util\";\nimport { dummyHandler } from \"../const/handler\";\nimport { HttpHandler } from \"msw\";\nimport { OnChangeFn, RowSelectionState, Updater } from \"@tanstack/react-table\";\nimport { isFunction } from \"lodash\";\n\nexport interface HandlerStoreState {\n worker: SetupWorker | null;\n /**\n * GraphQL or WebSocketHandler\n *\n * **Currently not supported**\n */\n restHandlers: Handler[];\n flattenHandlers: FlattenHandler[];\n handlerRowSelection: RowSelectionState;\n initMSWDevTool: (worker: SetupWorker) => SetupWorker;\n handleHandlerRowSelectionChange: OnChangeFn<RowSelectionState>;\n getWorker: () => SetupWorker;\n getTotalEnableHandlers: () => (Handler | HttpHandler)[];\n /**\n * This has to do with `msw` internal workings.\n * If I spread an empty array in `resetHandlers`, it will be replaced by `initialHandler`.\n * Therefore, I proposed the `clear` method, but unfortunately it was not accepted!\n */\n updateEnableHandlers: () => void;\n}\nexport const useHandlerStore = create<HandlerStoreState>((set, get) => ({\n flattenHandlers: [],\n worker: null,\n restHandlers: [],\n handlerRowSelection: {},\n initMSWDevTool: (_worker) => {\n const worker = _worker;\n set({ worker });\n const handlers = worker.listHandlers() as Handler[];\n const { flattenHandlers, unsupportedHandlers } = convertHandlers(handlers);\n set({ flattenHandlers });\n set({\n handlerRowSelection: flattenHandlers.reduce((acc, handler) => {\n acc[handler.id] = handler.enabled;\n return acc;\n }, {} as RowSelectionState),\n });\n set({ restHandlers: unsupportedHandlers });\n return worker;\n },\n handleHandlerRowSelectionChange: (updater) => {\n if (isFunction(updater)) {\n set(({ handlerRowSelection }) => {\n const next = updater(handlerRowSelection);\n const current = get().flattenHandlers.map((handler) =>\n next[handler.id]\n ? { ...handler, enabled: true }\n : { ...handler, enabled: false }\n );\n return { handlerRowSelection: next, flattenHandlers: current };\n });\n } else {\n const current = get().flattenHandlers.map((handler) =>\n updater[handler.id]\n ? { ...handler, enabled: true }\n : { ...handler, enabled: false }\n );\n set({ handlerRowSelection: updater, flattenHandlers: current });\n }\n get().updateEnableHandlers();\n },\n getWorker: () => {\n const worker = get().worker;\n if (!worker) throw new Error(\"Worker is not initialized\");\n return worker;\n },\n getTotalEnableHandlers: () => {\n const checkedHttpHandlers = get()\n .flattenHandlers.filter((h) => h.enabled)\n .map((h) => h.handler);\n const otherProtocolHandlers = get().restHandlers;\n return [...checkedHttpHandlers, ...otherProtocolHandlers];\n },\n updateEnableHandlers: () => {\n const worker = get().getWorker();\n const totalEnableHandlers = get().getTotalEnableHandlers();\n if (totalEnableHandlers.length === 0) {\n worker.resetHandlers(dummyHandler);\n return;\n }\n\n worker.resetHandlers(...totalEnableHandlers);\n },\n}));\n\nexport const initMSWDevTool = useHandlerStore.getState().initMSWDevTool;\n"],"names":["isFunction"],"mappings":";;;;;AA8BO,MAAM,eAAe,GAAG,MAAM,CAAoB,CAAC,GAAG,EAAE,GAAG,MAAM;AACtE,IAAA,eAAe,EAAE,EAAE;AACnB,IAAA,MAAM,EAAE,IAAI;AACZ,IAAA,YAAY,EAAE,EAAE;AAChB,IAAA,mBAAmB,EAAE,EAAE;AACvB,IAAA,cAAc,EAAE,CAAC,OAAO,KAAI;QAC1B,MAAM,MAAM,GAAG,OAAO,CAAC;AACvB,QAAA,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;AAChB,QAAA,MAAM,QAAQ,GAAG,MAAM,CAAC,YAAY,EAAe,CAAC;QACpD,MAAM,EAAE,eAAe,EAAE,mBAAmB,EAAE,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAC;AAC3E,QAAA,GAAG,CAAC,EAAE,eAAe,EAAE,CAAC,CAAC;AACzB,QAAA,GAAG,CAAC;YACF,mBAAmB,EAAE,eAAe,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,OAAO,KAAI;gBAC3D,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;AAClC,gBAAA,OAAO,GAAG,CAAC;aACZ,EAAE,EAAuB,CAAC;AAC5B,SAAA,CAAC,CAAC;AACH,QAAA,GAAG,CAAC,EAAE,YAAY,EAAE,mBAAmB,EAAE,CAAC,CAAC;AAC3C,QAAA,OAAO,MAAM,CAAC;KACf;AACD,IAAA,+BAA+B,EAAE,CAAC,OAAO,KAAI;AAC3C,QAAA,IAAIA,wBAAU,CAAC,OAAO,CAAC,EAAE;AACvB,YAAA,GAAG,CAAC,CAAC,EAAE,mBAA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OAAO,CAAC,CAAC;AACzB,QAAA,MAAM,qBAAqB,GAAG,GAAG,EAAE,CAAC,YAAY,CAAC;AACjD,QAAA,OAAO,CAAC,GAAG,mBAAmB,EAAE,GAAG,qBAAqB,CAAC,CAAC;KAC3D;IACD,oBAAoB,EAAE,MAAK;AACzB,QAAA,MAAM,MAAM,GAAG,GAAG,EAAE,CAAC,SAAS,EAAE,CAAC;AACjC,QAAA,MAAM,mBAAmB,GAAG,GAAG,EAAE,CAAC,sBAAsB,EAAE,CAAC;AAC3D,QAAA,IAAI,mBAAmB,CAAC,MAAM,KAAK,CAAC,EAAE;AACpC,YAAA,MAAM,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC;YACnC,OAAO;SACR;AAED,QAAA,MAAM,CAAC,aAAa,CAAC,GAAG,mBAAmB,CAAC,CAAC;KAC9C;AACF,CAAA,CAAC,EAAE;AAES,MAAA,cAAc,GAAG,eAAe,CAAC,QAAQ,EAAE,CAAC;;;;"}
@@ -1,14 +1,10 @@
1
- const flatHandlerMap = (handlerMap) => {
2
- return Object.entries(handlerMap).flatMap(([url, methods]) => Object.entries(methods).map(([method, { handler, checked }]) => ({
3
- url,
4
- method,
5
- handler,
6
- checked,
7
- })));
8
- };
1
+ const getRowId = ({ path, method }) => JSON.stringify({
2
+ path,
3
+ method,
4
+ });
9
5
  const convertHandlers = (handlers) => {
10
6
  const unsupportedHandlers = [];
11
- const handlerMap = handlers.reduce((acc, _handler) => {
7
+ const flattenHandlers = handlers.reduce((acc, _handler) => {
12
8
  // Current, GraphQL & WebSocketHandler is not supported.
13
9
  const handler = _handler;
14
10
  if (!("info" in handler && handler.info.method && handler.info.path)) {
@@ -17,14 +13,17 @@ const convertHandlers = (handlers) => {
17
13
  }
18
14
  const { method: _method, path: _path } = handler.info;
19
15
  const [method, path] = [_method.toString(), _path.toString()];
20
- if (!acc[path]) {
21
- acc[path] = {};
22
- }
23
- acc[path][method] = { handler, checked: true };
16
+ acc.push({
17
+ id: getRowId({ path, method }),
18
+ path,
19
+ method,
20
+ enabled: true,
21
+ handler,
22
+ });
24
23
  return acc;
25
- }, {});
26
- return { handlerMap, unsupportedHandlers };
24
+ }, []);
25
+ return { flattenHandlers, unsupportedHandlers };
27
26
  };
28
27
 
29
- export { convertHandlers, flatHandlerMap };
28
+ export { convertHandlers, getRowId };
30
29
  //# sourceMappingURL=util.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"util.js","sources":["../../../src/lib/util.ts"],"sourcesContent":["import { HttpHandler } from \"msw\";\nimport { Handler, HandlerMap } from \"./type\";\n\nexport const flatHandlerMap = (handlerMap: HandlerMap) => {\n return Object.entries(handlerMap).flatMap(([url, methods]) =>\n Object.entries(methods).map(([method, { handler, checked }]) => ({\n url,\n method,\n handler,\n checked,\n }))\n );\n};\n\nexport const convertHandlers = (\n handlers: Handler[]\n) => {\n const unsupportedHandlers: Handler[] = [];\n const handlerMap = handlers.reduce((acc, _handler) => {\n // Current, GraphQL & WebSocketHandler is not supported.\n const handler = _handler as HttpHandler;\n if (!(\"info\" in handler && handler.info.method && handler.info.path)) {\n unsupportedHandlers.push(handler);\n return acc;\n }\n const { method: _method, path: _path } = handler.info;\n const [method, path] = [_method.toString(), _path.toString()];\n if (!acc[path]) {\n acc[path] = {};\n }\n acc[path][method] = { handler, checked: true };\n return acc;\n }, {} as HandlerMap);\n return {handlerMap, unsupportedHandlers};\n};\n"],"names":[],"mappings":"AAGa,MAAA,cAAc,GAAG,CAAC,UAAsB,KAAI;AACvD,IAAA,OAAO,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,OAAO,CAAC,KACvD,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,MAAM;QAC/D,GAAG;QACH,MAAM;QACN,OAAO;QACP,OAAO;KACR,CAAC,CAAC,CACJ,CAAC;AACJ,EAAE;AAEW,MAAA,eAAe,GAAG,CAC7B,QAAmB,KACjB;IACF,MAAM,mBAAmB,GAAc,EAAE,CAAC;IAC1C,MAAM,UAAU,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,QAAQ,KAAI;;QAEnD,MAAM,OAAO,GAAG,QAAuB,CAAC;AACxC,QAAA,IAAI,EAAE,MAAM,IAAI,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;AACpE,YAAA,mBAAmB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AAClC,YAAA,OAAO,GAAG,CAAC;SACZ;AACD,QAAA,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;AACtD,QAAA,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC;AAC9D,QAAA,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;AACd,YAAA,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;SAChB;AACD,QAAA,GAAG,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAC/C,QAAA,OAAO,GAAG,CAAC;KACZ,EAAE,EAAgB,CAAC,CAAC;AACrB,IAAA,OAAO,EAAC,UAAU,EAAE,mBAAmB,EAAC,CAAC;AAC3C;;;;"}
1
+ {"version":3,"file":"util.js","sources":["../../../src/lib/util.ts"],"sourcesContent":["import { HttpHandler } from \"msw\";\nimport { FlattenHandler, Handler } from \"./type\";\n\nexport const getRowId = ({ path, method }: { path: string; method: string }) =>\n JSON.stringify({\n path,\n method,\n });\n\nexport const getObjFromRowId = (rowId: string) =>\n JSON.parse(rowId) as { path: string; method: string };\n\nexport const convertHandlers = (handlers: Handler[]) => {\n const unsupportedHandlers: Handler[] = [];\n const flattenHandlers: FlattenHandler[] = handlers.reduce((acc, _handler) => {\n // Current, GraphQL & WebSocketHandler is not supported.\n const handler = _handler as HttpHandler;\n if (!(\"info\" in handler && handler.info.method && handler.info.path)) {\n unsupportedHandlers.push(handler);\n return acc;\n }\n const { method: _method, path: _path } = handler.info;\n const [method, path] = [_method.toString(), _path.toString()];\n acc.push({\n id: getRowId({ path, method }),\n path,\n method,\n enabled: true,\n handler,\n });\n return acc;\n }, [] as FlattenHandler[]);\n return { flattenHandlers, unsupportedHandlers };\n};\n"],"names":[],"mappings":"AAGa,MAAA,QAAQ,GAAG,CAAC,EAAE,IAAI,EAAE,MAAM,EAAoC,KACzE,IAAI,CAAC,SAAS,CAAC;IACb,IAAI;IACJ,MAAM;AACP,CAAA,EAAE;AAKQ,MAAA,eAAe,GAAG,CAAC,QAAmB,KAAI;IACrD,MAAM,mBAAmB,GAAc,EAAE,CAAC;IAC1C,MAAM,eAAe,GAAqB,QAAQ,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,QAAQ,KAAI;;QAE1E,MAAM,OAAO,GAAG,QAAuB,CAAC;AACxC,QAAA,IAAI,EAAE,MAAM,IAAI,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;AACpE,YAAA,mBAAmB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AAClC,YAAA,OAAO,GAAG,CAAC;SACZ;AACD,QAAA,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;AACtD,QAAA,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC;QAC9D,GAAG,CAAC,IAAI,CAAC;YACP,EAAE,EAAE,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;YAC9B,IAAI;YACJ,MAAM;AACN,YAAA,OAAO,EAAE,IAAI;YACb,OAAO;AACR,SAAA,CAAC,CAAC;AACH,QAAA,OAAO,GAAG,CAAC;KACZ,EAAE,EAAsB,CAAC,CAAC;AAC3B,IAAA,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,CAAC;AAClD;;;;"}
@@ -1 +1 @@
1
- .entry-msw-dev-tool{align-items:center;background-color:#3498db;border:2px solid #3498db;border-radius:5px;color:#fff;cursor:pointer;display:flex;font-size:1rem;font-size:30px;font-weight:700;height:50px;justify-content:center;left:10px;position:absolute;text-align:center;text-decoration:none;text-transform:uppercase;top:10px;transition:all .3s ease;width:50px;z-index:999}.msw-dev-tool-container{background-color:#fff;border:1px solid #000;box-sizing:border-box;color:#000;left:0;padding:1.5rem;position:absolute;top:0;width:100%;z-index:1000}.msw-dev-tool-title-container{display:flex;justify-content:space-between}
1
+ .entry-msw-dev-tool{align-items:center;background-color:#3498db;border:2px solid #3498db;border-radius:5px;color:#fff;cursor:pointer;display:flex;font-size:1rem;font-size:30px;font-weight:700;height:50px;justify-content:center;left:10px;position:absolute;text-align:center;text-decoration:none;text-transform:uppercase;top:10px;transition:all .3s ease;width:50px;z-index:999}.msw-dev-tool-container{background-color:#fff;border:1px solid #000;box-sizing:border-box;color:#000;left:0;padding:1.5rem;position:absolute;top:0;width:100%;z-index:1000}.msw-dev-tool-title-container{display:flex;justify-content:space-between}.msw-dev-tool-center{align-items:center;display:flex;justify-content:center}
@@ -0,0 +1,75 @@
1
+ import * as React from 'react';
2
+ import { createTable } from '../../../table-core/build/lib/index.js';
3
+ export { ColumnFaceting, ColumnFiltering, ColumnGrouping, ColumnOrdering, ColumnPinning, ColumnSizing, ColumnVisibility, GlobalFaceting, GlobalFiltering, Headers, RowExpanding, RowPagination, RowPinning, RowSelection, RowSorting, _getVisibleLeafColumns, aggregationFns, buildHeaderGroups, createCell, createColumn, createColumnHelper, createRow, defaultColumnSizing, filterFns, flattenBy, functionalUpdate, getCoreRowModel, getMemoOptions, isFunction, isNumberArray, isRowSelected, isSubRowSelected, makeStateUpdater, memo, orderColumns, passiveEventSupported, reSplitAlphaNumeric, selectRowsFn, shouldAutoRemoveFilter, sortingFns } from '../../../table-core/build/lib/index.js';
4
+
5
+ /**
6
+ * react-table
7
+ *
8
+ * Copyright (c) TanStack
9
+ *
10
+ * This source code is licensed under the MIT license found in the
11
+ * LICENSE.md file in the root directory of this source tree.
12
+ *
13
+ * @license MIT
14
+ */
15
+
16
+ //
17
+
18
+ /**
19
+ * If rendering headers, cells, or footers with custom markup, use flexRender instead of `cell.getValue()` or `cell.renderValue()`.
20
+ */
21
+ function flexRender(Comp, props) {
22
+ return !Comp ? null : isReactComponent(Comp) ? /*#__PURE__*/React.createElement(Comp, props) : Comp;
23
+ }
24
+ function isReactComponent(component) {
25
+ return isClassComponent(component) || typeof component === 'function' || isExoticComponent(component);
26
+ }
27
+ function isClassComponent(component) {
28
+ return typeof component === 'function' && (() => {
29
+ const proto = Object.getPrototypeOf(component);
30
+ return proto.prototype && proto.prototype.isReactComponent;
31
+ })();
32
+ }
33
+ function isExoticComponent(component) {
34
+ return typeof component === 'object' && typeof component.$$typeof === 'symbol' && ['react.memo', 'react.forward_ref'].includes(component.$$typeof.description);
35
+ }
36
+ function useReactTable(options) {
37
+ // Compose in the generic options to the user options
38
+ const resolvedOptions = {
39
+ state: {},
40
+ // Dummy state
41
+ onStateChange: () => {},
42
+ // noop
43
+ renderFallbackValue: null,
44
+ ...options
45
+ };
46
+
47
+ // Create a new table and store it in state
48
+ const [tableRef] = React.useState(() => ({
49
+ current: createTable(resolvedOptions)
50
+ }));
51
+
52
+ // By default, manage table state here using the table's initial state
53
+ const [state, setState] = React.useState(() => tableRef.current.initialState);
54
+
55
+ // Compose the default state above with any user state. This will allow the user
56
+ // to only control a subset of the state if desired.
57
+ tableRef.current.setOptions(prev => ({
58
+ ...prev,
59
+ ...options,
60
+ state: {
61
+ ...state,
62
+ ...options.state
63
+ },
64
+ // Similarly, we'll maintain both our internal state and any user-provided
65
+ // state.
66
+ onStateChange: updater => {
67
+ setState(updater);
68
+ options.onStateChange == null || options.onStateChange(updater);
69
+ }
70
+ }));
71
+ return tableRef.current;
72
+ }
73
+
74
+ export { createTable, flexRender, useReactTable };
75
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../../../../../node_modules/@tanstack/react-table/build/lib/index.mjs"],"sourcesContent":["/**\n * react-table\n *\n * Copyright (c) TanStack\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE.md file in the root directory of this source tree.\n *\n * @license MIT\n */\nimport * as React from 'react';\nimport { createTable } from '@tanstack/table-core';\nexport * from '@tanstack/table-core';\n\n//\n\n/**\n * If rendering headers, cells, or footers with custom markup, use flexRender instead of `cell.getValue()` or `cell.renderValue()`.\n */\nfunction flexRender(Comp, props) {\n return !Comp ? null : isReactComponent(Comp) ? /*#__PURE__*/React.createElement(Comp, props) : Comp;\n}\nfunction isReactComponent(component) {\n return isClassComponent(component) || typeof component === 'function' || isExoticComponent(component);\n}\nfunction isClassComponent(component) {\n return typeof component === 'function' && (() => {\n const proto = Object.getPrototypeOf(component);\n return proto.prototype && proto.prototype.isReactComponent;\n })();\n}\nfunction isExoticComponent(component) {\n return typeof component === 'object' && typeof component.$$typeof === 'symbol' && ['react.memo', 'react.forward_ref'].includes(component.$$typeof.description);\n}\nfunction useReactTable(options) {\n // Compose in the generic options to the user options\n const resolvedOptions = {\n state: {},\n // Dummy state\n onStateChange: () => {},\n // noop\n renderFallbackValue: null,\n ...options\n };\n\n // Create a new table and store it in state\n const [tableRef] = React.useState(() => ({\n current: createTable(resolvedOptions)\n }));\n\n // By default, manage table state here using the table's initial state\n const [state, setState] = React.useState(() => tableRef.current.initialState);\n\n // Compose the default state above with any user state. This will allow the user\n // to only control a subset of the state if desired.\n tableRef.current.setOptions(prev => ({\n ...prev,\n ...options,\n state: {\n ...state,\n ...options.state\n },\n // Similarly, we'll maintain both our internal state and any user-provided\n // state.\n onStateChange: updater => {\n setState(updater);\n options.onStateChange == null || options.onStateChange(updater);\n }\n }));\n return tableRef.current;\n}\n\nexport { flexRender, useReactTable };\n//# sourceMappingURL=index.mjs.map\n"],"names":[],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,UAAU,CAAC,IAAI,EAAE,KAAK,EAAE;AACjC,EAAE,OAAO,CAAC,IAAI,GAAG,IAAI,GAAG,gBAAgB,CAAC,IAAI,CAAC,gBAAgB,KAAK,CAAC,aAAa,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,IAAI,CAAC;AACtG,CAAC;AACD,SAAS,gBAAgB,CAAC,SAAS,EAAE;AACrC,EAAE,OAAO,gBAAgB,CAAC,SAAS,CAAC,IAAI,OAAO,SAAS,KAAK,UAAU,IAAI,iBAAiB,CAAC,SAAS,CAAC,CAAC;AACxG,CAAC;AACD,SAAS,gBAAgB,CAAC,SAAS,EAAE;AACrC,EAAE,OAAO,OAAO,SAAS,KAAK,UAAU,IAAI,CAAC,MAAM;AACnD,IAAI,MAAM,KAAK,GAAG,MAAM,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;AACnD,IAAI,OAAO,KAAK,CAAC,SAAS,IAAI,KAAK,CAAC,SAAS,CAAC,gBAAgB,CAAC;AAC/D,GAAG,GAAG,CAAC;AACP,CAAC;AACD,SAAS,iBAAiB,CAAC,SAAS,EAAE;AACtC,EAAE,OAAO,OAAO,SAAS,KAAK,QAAQ,IAAI,OAAO,SAAS,CAAC,QAAQ,KAAK,QAAQ,IAAI,CAAC,YAAY,EAAE,mBAAmB,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;AACjK,CAAC;AACD,SAAS,aAAa,CAAC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