@window-splitter/react 0.8.0

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 (81) hide show
  1. package/.storybook/main.ts +17 -0
  2. package/.storybook/preview.ts +14 -0
  3. package/.tshy/build.json +8 -0
  4. package/.tshy/commonjs.json +19 -0
  5. package/.tshy/esm.json +18 -0
  6. package/.turbo/turbo-build.log +5 -0
  7. package/.turbo/turbo-lint.log +5 -0
  8. package/CHANGELOG.md +606 -0
  9. package/README.md +53 -0
  10. package/dist/commonjs/ReactWindowSplitter.d.ts +19 -0
  11. package/dist/commonjs/ReactWindowSplitter.d.ts.map +1 -0
  12. package/dist/commonjs/ReactWindowSplitter.js +558 -0
  13. package/dist/commonjs/ReactWindowSplitter.js.map +1 -0
  14. package/dist/commonjs/ReactWindowSplitter.stories.d.ts +47 -0
  15. package/dist/commonjs/ReactWindowSplitter.stories.d.ts.map +1 -0
  16. package/dist/commonjs/ReactWindowSplitter.stories.js +330 -0
  17. package/dist/commonjs/ReactWindowSplitter.stories.js.map +1 -0
  18. package/dist/commonjs/ReactWindowSplitter.test.d.ts +2 -0
  19. package/dist/commonjs/ReactWindowSplitter.test.d.ts.map +1 -0
  20. package/dist/commonjs/ReactWindowSplitter.test.js +219 -0
  21. package/dist/commonjs/ReactWindowSplitter.test.js.map +1 -0
  22. package/dist/commonjs/bundle.size.d.ts +2 -0
  23. package/dist/commonjs/bundle.size.d.ts.map +1 -0
  24. package/dist/commonjs/bundle.size.js +29 -0
  25. package/dist/commonjs/bundle.size.js.map +1 -0
  26. package/dist/commonjs/index.d.ts +3 -0
  27. package/dist/commonjs/index.d.ts.map +1 -0
  28. package/dist/commonjs/index.js +18 -0
  29. package/dist/commonjs/index.js.map +1 -0
  30. package/dist/commonjs/package.json +3 -0
  31. package/dist/commonjs/useIndexedChildren.d.ts +8 -0
  32. package/dist/commonjs/useIndexedChildren.d.ts.map +1 -0
  33. package/dist/commonjs/useIndexedChildren.js +81 -0
  34. package/dist/commonjs/useIndexedChildren.js.map +1 -0
  35. package/dist/commonjs/useMove.d.ts +8 -0
  36. package/dist/commonjs/useMove.d.ts.map +1 -0
  37. package/dist/commonjs/useMove.js +19 -0
  38. package/dist/commonjs/useMove.js.map +1 -0
  39. package/dist/esm/ReactWindowSplitter.d.ts +19 -0
  40. package/dist/esm/ReactWindowSplitter.d.ts.map +1 -0
  41. package/dist/esm/ReactWindowSplitter.js +532 -0
  42. package/dist/esm/ReactWindowSplitter.js.map +1 -0
  43. package/dist/esm/ReactWindowSplitter.stories.d.ts +47 -0
  44. package/dist/esm/ReactWindowSplitter.stories.d.ts.map +1 -0
  45. package/dist/esm/ReactWindowSplitter.stories.js +286 -0
  46. package/dist/esm/ReactWindowSplitter.stories.js.map +1 -0
  47. package/dist/esm/ReactWindowSplitter.test.d.ts +2 -0
  48. package/dist/esm/ReactWindowSplitter.test.d.ts.map +1 -0
  49. package/dist/esm/ReactWindowSplitter.test.js +191 -0
  50. package/dist/esm/ReactWindowSplitter.test.js.map +1 -0
  51. package/dist/esm/bundle.size.d.ts +2 -0
  52. package/dist/esm/bundle.size.d.ts.map +1 -0
  53. package/dist/esm/bundle.size.js +4 -0
  54. package/dist/esm/bundle.size.js.map +1 -0
  55. package/dist/esm/index.d.ts +3 -0
  56. package/dist/esm/index.d.ts.map +1 -0
  57. package/dist/esm/index.js +2 -0
  58. package/dist/esm/index.js.map +1 -0
  59. package/dist/esm/package.json +3 -0
  60. package/dist/esm/useIndexedChildren.d.ts +8 -0
  61. package/dist/esm/useIndexedChildren.d.ts.map +1 -0
  62. package/dist/esm/useIndexedChildren.js +54 -0
  63. package/dist/esm/useIndexedChildren.js.map +1 -0
  64. package/dist/esm/useMove.d.ts +8 -0
  65. package/dist/esm/useMove.d.ts.map +1 -0
  66. package/dist/esm/useMove.js +16 -0
  67. package/dist/esm/useMove.js.map +1 -0
  68. package/eslint.config.js +3 -0
  69. package/package.json +108 -0
  70. package/rsbuild.config.js +25 -0
  71. package/src/ReactWindowSplitter.stories.tsx +705 -0
  72. package/src/ReactWindowSplitter.test.tsx +384 -0
  73. package/src/ReactWindowSplitter.tsx +884 -0
  74. package/src/__snapshots__/ReactWindowSplitter.test.tsx.snap +58 -0
  75. package/src/bundle.size.ts +4 -0
  76. package/src/index.ts +2 -0
  77. package/src/useIndexedChildren.tsx +79 -0
  78. package/src/useMove.ts +22 -0
  79. package/tsconfig.json +6 -0
  80. package/vitest.config.ts +20 -0
  81. package/vitest.setup.ts +7 -0
@@ -0,0 +1,219 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ const react_1 = __importDefault(require("react"));
30
+ const vitest_1 = require("vitest");
31
+ const react_2 = require("@testing-library/react");
32
+ const Cookies = __importStar(require("tiny-cookie"));
33
+ const ReactWindowSplitter_stories_js_1 = require("./ReactWindowSplitter.stories.js");
34
+ const ReactWindowSplitter_js_1 = require("./ReactWindowSplitter.js");
35
+ const test_1 = require("@window-splitter/interface/test");
36
+ const { expectTemplate, waitForMeasurement, waitForCondition } = (0, test_1.createTestUtils)({ waitFor: react_2.waitFor });
37
+ (0, vitest_1.test)("horizontal layout", async () => {
38
+ const handle = { current: null };
39
+ const { getByText } = (0, react_2.render)(react_1.default.createElement("div", { style: { width: 500 } },
40
+ react_1.default.createElement(ReactWindowSplitter_stories_js_1.Simple, { handle: handle })));
41
+ await waitForMeasurement(handle.current);
42
+ (0, vitest_1.expect)(getByText("Panel 1")).toBeInTheDocument();
43
+ (0, vitest_1.expect)(getByText("Panel 2")).toBeInTheDocument();
44
+ await expectTemplate(handle.current, "244px 10px 244px");
45
+ // Should respect the min
46
+ await (0, test_1.dragHandle)({ delta: 300 });
47
+ await expectTemplate(handle.current, "388px 10px 100px");
48
+ });
49
+ (0, vitest_1.test)("vertical layout", async () => {
50
+ const handle = { current: null };
51
+ const { getByText } = (0, react_2.render)(react_1.default.createElement("div", { style: { width: 500 } },
52
+ react_1.default.createElement(ReactWindowSplitter_stories_js_1.VerticalLayout, { handle: handle })));
53
+ await waitForMeasurement(handle.current);
54
+ (0, vitest_1.expect)(getByText("top")).toBeInTheDocument();
55
+ (0, vitest_1.expect)(getByText("middle")).toBeInTheDocument();
56
+ (0, vitest_1.expect)(getByText("bottom")).toBeInTheDocument();
57
+ await expectTemplate(handle.current, "96px 10px 108px 10px 96px");
58
+ // Should respect the min
59
+ await (0, test_1.dragHandle)({ delta: 100, orientation: "vertical" });
60
+ await expectTemplate(handle.current, "172px 10px 64px 10px 64px");
61
+ });
62
+ (0, vitest_1.test)("Conditional Panels", async () => {
63
+ const handle = { current: null };
64
+ const { getByText } = (0, react_2.render)(react_1.default.createElement("div", { style: { width: 500 } },
65
+ react_1.default.createElement(ReactWindowSplitter_stories_js_1.ConditionalPanel, { handle: handle })));
66
+ await waitForMeasurement(handle.current);
67
+ await expectTemplate(handle.current, "244px 10px 244px");
68
+ getByText("Expand").click();
69
+ await expectTemplate(handle.current, "236.953125px 10px 141.046875px 10px 100px");
70
+ getByText("Close").click();
71
+ await expectTemplate(handle.current, "236.96875px 10px 251.03125px");
72
+ });
73
+ (0, vitest_1.test)("Dynamic constraints", async () => {
74
+ const handle = { current: null };
75
+ const { getByText } = (0, react_2.render)(react_1.default.createElement("div", { style: { width: 1000 } },
76
+ react_1.default.createElement(ReactWindowSplitter_stories_js_1.DynamicConstraints, { handle: handle })));
77
+ await waitForMeasurement(handle.current);
78
+ await expectTemplate(handle.current, "100px 10px 178px 10px 700px");
79
+ getByText("Toggle Custom").click();
80
+ await expectTemplate(handle.current, "500px 10px 178px 10px 300px");
81
+ getByText("Toggle Custom").click();
82
+ await expectTemplate(handle.current, "400px 10px 178px 10px 400px");
83
+ });
84
+ (0, vitest_1.describe)("Autosave", () => {
85
+ (0, vitest_1.test)("localStorage", async () => {
86
+ localStorage.clear();
87
+ const handle = { current: null };
88
+ (0, react_2.render)(react_1.default.createElement("div", { style: { width: 500 } },
89
+ react_1.default.createElement(ReactWindowSplitter_stories_js_1.Autosave, { handle: handle })));
90
+ await waitForMeasurement(handle.current);
91
+ await expectTemplate(handle.current, "244px 10px 244px");
92
+ await (0, test_1.dragHandle)({ delta: 100 });
93
+ await expectTemplate(handle.current, "342px 10px 146px");
94
+ await waitForCondition(() => Boolean(localStorage.getItem("autosave-example")));
95
+ const obj = JSON.parse(localStorage.getItem("autosave-example") || "{}");
96
+ (0, vitest_1.expect)(obj.items).toMatchSnapshot();
97
+ });
98
+ (0, vitest_1.test)("callback", async () => {
99
+ localStorage.clear();
100
+ const handle = { current: null };
101
+ const spy = vitest_1.vi.fn();
102
+ (0, react_2.render)(react_1.default.createElement("div", { style: { width: 500 } },
103
+ react_1.default.createElement(ReactWindowSplitter_stories_js_1.AutosaveCollapsible, { handle: handle, onCollapseChange: spy })));
104
+ await (0, test_1.dragHandle)({ delta: -200 });
105
+ await expectTemplate(handle.current, "100px 10px 388px");
106
+ (0, vitest_1.expect)(spy).toHaveBeenCalledWith(true);
107
+ (0, react_2.cleanup)();
108
+ (0, react_2.render)(react_1.default.createElement("div", { style: { width: 500 } },
109
+ react_1.default.createElement(ReactWindowSplitter_stories_js_1.AutosaveCollapsible, { handle: handle, onCollapseChange: spy })));
110
+ await expectTemplate(handle.current, "100px 10px 388px");
111
+ await (0, test_1.dragHandle)({ delta: 200 });
112
+ (0, vitest_1.expect)(spy).toHaveBeenCalledWith(false);
113
+ });
114
+ (0, vitest_1.test)("cookie", async () => {
115
+ // clear cookies
116
+ document.cookie = "test=; expires=Thu, 01 Jan 1970 00:00:00 GMT";
117
+ const handle = { current: null };
118
+ (0, react_2.render)(react_1.default.createElement("div", { style: { width: 500 } },
119
+ react_1.default.createElement(ReactWindowSplitter_js_1.PanelGroup, { handle: handle, orientation: "horizontal", autosaveId: "autosave-cookie-example", autosaveStrategy: "cookie", style: { height: 200 } },
120
+ react_1.default.createElement(ReactWindowSplitter_js_1.Panel, { id: "panel1" }, "1"),
121
+ react_1.default.createElement(ReactWindowSplitter_js_1.PanelResizer, { id: "resizer1", size: "10px", style: { background: "red" } }),
122
+ react_1.default.createElement(ReactWindowSplitter_js_1.Panel, { id: "panel2" }, "2"))));
123
+ await waitForMeasurement(handle.current);
124
+ await expectTemplate(handle.current, "245px 10px 245px");
125
+ await (0, test_1.dragHandle)({ delta: 100 });
126
+ await expectTemplate(handle.current, "343px 10px 147px");
127
+ await waitForCondition(() => document.cookie.includes("autosave-cookie-example"));
128
+ (0, vitest_1.expect)(document.cookie).toMatchSnapshot();
129
+ const snapshot = Cookies.get("autosave-cookie-example");
130
+ (0, react_2.cleanup)();
131
+ (0, react_2.render)(react_1.default.createElement("div", { style: { width: 500 } },
132
+ react_1.default.createElement(ReactWindowSplitter_js_1.PanelGroup, { handle: handle, orientation: "horizontal", autosaveId: "autosave-cookie-example", autosaveStrategy: "cookie", style: { height: 200 }, snapshot: snapshot ? JSON.parse(snapshot) : undefined },
133
+ react_1.default.createElement(ReactWindowSplitter_js_1.Panel, { id: "panel1" }, "1"),
134
+ react_1.default.createElement(ReactWindowSplitter_js_1.PanelResizer, { id: "resizer1", size: "10px", style: { background: "red" } }),
135
+ react_1.default.createElement(ReactWindowSplitter_js_1.Panel, { id: "panel2" }, "2"))));
136
+ await expectTemplate(handle.current, "343px 10px 147px");
137
+ });
138
+ });
139
+ (0, vitest_1.test)("Keyboard interactions with collapsed panels", async () => {
140
+ const handle = { current: null };
141
+ const rightHandle = { current: null };
142
+ (0, react_2.render)(react_1.default.createElement("div", { style: { width: 500 } },
143
+ react_1.default.createElement(ReactWindowSplitter_stories_js_1.Collapsible, { handle: handle, rightPanelHandle: rightHandle })));
144
+ await waitForMeasurement(handle.current);
145
+ await expectTemplate(handle.current, "209px 10px 209px 10px 60px");
146
+ const resizer2 = document.getElementById("resizer-2");
147
+ react_2.fireEvent.keyDown(resizer2, { key: "Enter" });
148
+ await expectTemplate(handle.current, "209px 10px 168.953125px 10px 100.03125px");
149
+ react_2.fireEvent.keyDown(resizer2, { key: "ArrowLeft" });
150
+ react_2.fireEvent.keyDown(resizer2, { key: "ArrowLeft" });
151
+ react_2.fireEvent.keyDown(resizer2, { key: "ArrowLeft" });
152
+ react_2.fireEvent.keyDown(resizer2, { key: "ArrowLeft" });
153
+ await expectTemplate(handle.current, "209px 10px 164.96875px 10px 104.03125px");
154
+ react_2.fireEvent.keyDown(resizer2, { key: "ArrowLeft", shiftKey: true });
155
+ await expectTemplate(handle.current, "209px 10px 149.96875px 10px 119.03125px");
156
+ react_2.fireEvent.keyDown(resizer2, { key: "Enter" });
157
+ await expectTemplate(handle.current, "209px 10px 209px 10px 60px");
158
+ react_2.fireEvent.keyDown(resizer2, { key: "Enter" });
159
+ await expectTemplate(handle.current, "209px 10px 149.96875px 10px 119.03125px");
160
+ });
161
+ (0, vitest_1.describe)("imperative panel API", async () => {
162
+ (0, vitest_1.test)("panel group", async () => {
163
+ const handle = { current: null };
164
+ (0, react_2.render)(react_1.default.createElement("div", { style: { width: 500 } },
165
+ react_1.default.createElement(ReactWindowSplitter_stories_js_1.Collapsible, { handle: handle })));
166
+ await waitForMeasurement(handle.current);
167
+ (0, vitest_1.expect)(handle.current.getPercentageSizes()).toMatchInlineSnapshot(`
168
+ [
169
+ 0.5,
170
+ 0.020080321285140562,
171
+ 0.5,
172
+ 0.020080321285140562,
173
+ 0.12048192771084337,
174
+ ]
175
+ `);
176
+ (0, vitest_1.expect)(handle.current.getPixelSizes()).toMatchInlineSnapshot(`
177
+ [
178
+ 209,
179
+ 10,
180
+ 209,
181
+ 10,
182
+ 60,
183
+ ]
184
+ `);
185
+ await expectTemplate(handle.current, "209px 10px 209px 10px 60px");
186
+ });
187
+ (0, vitest_1.test)("panel", async () => {
188
+ const handle = { current: null };
189
+ const rightHandle = { current: null };
190
+ const leftHandle = { current: null };
191
+ (0, react_2.render)(react_1.default.createElement("div", { style: { width: 500 } },
192
+ react_1.default.createElement(ReactWindowSplitter_stories_js_1.Collapsible, { handle: handle, leftPanelHandle: leftHandle, rightPanelHandle: rightHandle })));
193
+ await waitForMeasurement(handle.current);
194
+ (0, vitest_1.expect)(rightHandle.current.isCollapsed()).toBe(true);
195
+ (0, vitest_1.expect)(rightHandle.current.isExpanded()).toBe(false);
196
+ rightHandle.current.expand();
197
+ await new Promise((resolve) => setTimeout(resolve, 2000));
198
+ (0, vitest_1.expect)(rightHandle.current.isCollapsed()).toBe(false);
199
+ (0, vitest_1.expect)(rightHandle.current.isExpanded()).toBe(true);
200
+ rightHandle.current.collapse();
201
+ await new Promise((resolve) => setTimeout(resolve, 2000));
202
+ (0, vitest_1.expect)(rightHandle.current.isCollapsed()).toBe(true);
203
+ (0, vitest_1.expect)(rightHandle.current.isExpanded()).toBe(false);
204
+ // Test the non controlled version
205
+ (0, vitest_1.expect)(leftHandle.current.isCollapsed()).toBe(false);
206
+ (0, vitest_1.expect)(leftHandle.current.isExpanded()).toBe(true);
207
+ leftHandle.current.collapse();
208
+ await new Promise((resolve) => setTimeout(resolve, 2000));
209
+ (0, vitest_1.expect)(leftHandle.current.isCollapsed()).toBe(true);
210
+ (0, vitest_1.expect)(leftHandle.current.isExpanded()).toBe(false);
211
+ (0, vitest_1.expect)(rightHandle.current.getPercentageSize()).toBe(leftHandle.current.getPercentageSize());
212
+ (0, vitest_1.expect)(rightHandle.current.getPixelSize()).toBe(leftHandle.current.getPixelSize());
213
+ leftHandle.current.expand();
214
+ await new Promise((resolve) => setTimeout(resolve, 5000));
215
+ (0, vitest_1.expect)(leftHandle.current.isCollapsed()).toBe(false);
216
+ (0, vitest_1.expect)(leftHandle.current.isExpanded()).toBe(true);
217
+ });
218
+ });
219
+ //# sourceMappingURL=ReactWindowSplitter.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ReactWindowSplitter.test.js","sourceRoot":"","sources":["../../src/ReactWindowSplitter.test.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAA0B;AAC1B,mCAAoD;AACpD,kDAA6E;AAC7E,qDAAuC;AAGvC,qFAQ0C;AAC1C,qEAA2E;AAC3E,0DAA8E;AAE9E,MAAM,EAAE,cAAc,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,GAC5D,IAAA,sBAAe,EAAC,EAAE,OAAO,EAAP,eAAO,EAAE,CAAC,CAAC;AAE/B,IAAA,aAAI,EAAC,mBAAmB,EAAE,KAAK,IAAI,EAAE;IACnC,MAAM,MAAM,GAAG,EAAE,OAAO,EAAE,IAAI,EAE7B,CAAC;IACF,MAAM,EAAE,SAAS,EAAE,GAAG,IAAA,cAAM,EAC1B,uCAAK,KAAK,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE;QACxB,8BAAC,uCAAM,IAAC,MAAM,EAAE,MAAM,GAAI,CACtB,CACP,CAAC;IAEF,MAAM,kBAAkB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAEzC,IAAA,eAAM,EAAC,SAA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IAAI,CAC7C,UAAU,CAAC,OAAO,CAAC,YAAY,EAAE,CAClC,CAAC;QAEF,UAAU,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;QAC5B,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC;QAE1D,IAAA,eAAM,EAAC,UAAU,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACrD,IAAA,eAAM,EAAC,UAAU,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACrD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import React from \"react\";\nimport { test, expect, describe, vi } from \"vitest\";\nimport { cleanup, fireEvent, render, waitFor } from \"@testing-library/react\";\nimport * as Cookies from \"tiny-cookie\";\n\nimport { PanelGroupHandle, PanelHandle } from \"@window-splitter/interface\";\nimport {\n Autosave,\n AutosaveCollapsible,\n Collapsible,\n ConditionalPanel,\n Simple,\n VerticalLayout,\n DynamicConstraints,\n} from \"./ReactWindowSplitter.stories.js\";\nimport { PanelResizer, PanelGroup, Panel } from \"./ReactWindowSplitter.js\";\nimport { createTestUtils, dragHandle } from \"@window-splitter/interface/test\";\n\nconst { expectTemplate, waitForMeasurement, waitForCondition } =\n createTestUtils({ waitFor });\n\ntest(\"horizontal layout\", async () => {\n const handle = { current: null } as unknown as {\n current: PanelGroupHandle;\n };\n const { getByText } = render(\n <div style={{ width: 500 }}>\n <Simple handle={handle} />\n </div>\n );\n\n await waitForMeasurement(handle.current);\n\n expect(getByText(\"Panel 1\")).toBeInTheDocument();\n expect(getByText(\"Panel 2\")).toBeInTheDocument();\n\n await expectTemplate(handle.current, \"244px 10px 244px\");\n\n // Should respect the min\n await dragHandle({ delta: 300 });\n await expectTemplate(handle.current, \"388px 10px 100px\");\n});\n\ntest(\"vertical layout\", async () => {\n const handle = { current: null } as unknown as {\n current: PanelGroupHandle;\n };\n const { getByText } = render(\n <div style={{ width: 500 }}>\n <VerticalLayout handle={handle} />\n </div>\n );\n\n await waitForMeasurement(handle.current);\n\n expect(getByText(\"top\")).toBeInTheDocument();\n expect(getByText(\"middle\")).toBeInTheDocument();\n expect(getByText(\"bottom\")).toBeInTheDocument();\n\n await expectTemplate(handle.current, \"96px 10px 108px 10px 96px\");\n\n // Should respect the min\n await dragHandle({ delta: 100, orientation: \"vertical\" });\n await expectTemplate(handle.current, \"172px 10px 64px 10px 64px\");\n});\n\ntest(\"Conditional Panels\", async () => {\n const handle = { current: null } as unknown as {\n current: PanelGroupHandle;\n };\n const { getByText } = render(\n <div style={{ width: 500 }}>\n <ConditionalPanel handle={handle} />\n </div>\n );\n\n await waitForMeasurement(handle.current);\n await expectTemplate(handle.current, \"244px 10px 244px\");\n\n getByText(\"Expand\").click();\n await expectTemplate(\n handle.current,\n \"236.953125px 10px 141.046875px 10px 100px\"\n );\n\n getByText(\"Close\").click();\n await expectTemplate(handle.current, \"236.96875px 10px 251.03125px\");\n});\n\ntest(\"Dynamic constraints\", async () => {\n const handle = { current: null } as unknown as {\n current: PanelGroupHandle;\n };\n const { getByText } = render(\n <div style={{ width: 1000 }}>\n <DynamicConstraints handle={handle} />\n </div>\n );\n\n await waitForMeasurement(handle.current);\n await expectTemplate(handle.current, \"100px 10px 178px 10px 700px\");\n\n getByText(\"Toggle Custom\").click();\n await expectTemplate(handle.current, \"500px 10px 178px 10px 300px\");\n\n getByText(\"Toggle Custom\").click();\n await expectTemplate(handle.current, \"400px 10px 178px 10px 400px\");\n});\n\ndescribe(\"Autosave\", () => {\n test(\"localStorage\", async () => {\n localStorage.clear();\n\n const handle = { current: null } as unknown as {\n current: PanelGroupHandle;\n };\n\n render(\n <div style={{ width: 500 }}>\n <Autosave handle={handle} />\n </div>\n );\n\n await waitForMeasurement(handle.current);\n await expectTemplate(handle.current, \"244px 10px 244px\");\n\n await dragHandle({ delta: 100 });\n await expectTemplate(handle.current, \"342px 10px 146px\");\n\n await waitForCondition(() =>\n Boolean(localStorage.getItem(\"autosave-example\"))\n );\n const obj = JSON.parse(localStorage.getItem(\"autosave-example\") || \"{}\");\n expect(obj.items).toMatchSnapshot();\n });\n\n test(\"callback\", async () => {\n localStorage.clear();\n\n const handle = { current: null } as unknown as {\n current: PanelGroupHandle;\n };\n\n const spy = vi.fn();\n\n render(\n <div style={{ width: 500 }}>\n <AutosaveCollapsible handle={handle} onCollapseChange={spy} />\n </div>\n );\n\n await dragHandle({ delta: -200 });\n await expectTemplate(handle.current, \"100px 10px 388px\");\n expect(spy).toHaveBeenCalledWith(true);\n\n cleanup();\n\n render(\n <div style={{ width: 500 }}>\n <AutosaveCollapsible handle={handle} onCollapseChange={spy} />\n </div>\n );\n\n await expectTemplate(handle.current, \"100px 10px 388px\");\n await dragHandle({ delta: 200 });\n expect(spy).toHaveBeenCalledWith(false);\n });\n\n test(\"cookie\", async () => {\n // clear cookies\n document.cookie = \"test=; expires=Thu, 01 Jan 1970 00:00:00 GMT\";\n\n const handle = { current: null } as unknown as {\n current: PanelGroupHandle;\n };\n\n render(\n <div style={{ width: 500 }}>\n <PanelGroup\n handle={handle}\n orientation=\"horizontal\"\n autosaveId=\"autosave-cookie-example\"\n autosaveStrategy=\"cookie\"\n style={{ height: 200 }}\n >\n <Panel id=\"panel1\">1</Panel>\n <PanelResizer\n id=\"resizer1\"\n size=\"10px\"\n style={{ background: \"red\" }}\n />\n <Panel id=\"panel2\">2</Panel>\n </PanelGroup>\n </div>\n );\n\n await waitForMeasurement(handle.current);\n await expectTemplate(handle.current, \"245px 10px 245px\");\n\n await dragHandle({ delta: 100 });\n await expectTemplate(handle.current, \"343px 10px 147px\");\n\n await waitForCondition(() =>\n document.cookie.includes(\"autosave-cookie-example\")\n );\n\n expect(document.cookie).toMatchSnapshot();\n\n const snapshot = Cookies.get(\"autosave-cookie-example\");\n\n cleanup();\n\n render(\n <div style={{ width: 500 }}>\n <PanelGroup\n handle={handle}\n orientation=\"horizontal\"\n autosaveId=\"autosave-cookie-example\"\n autosaveStrategy=\"cookie\"\n style={{ height: 200 }}\n snapshot={snapshot ? JSON.parse(snapshot) : undefined}\n >\n <Panel id=\"panel1\">1</Panel>\n <PanelResizer\n id=\"resizer1\"\n size=\"10px\"\n style={{ background: \"red\" }}\n />\n <Panel id=\"panel2\">2</Panel>\n </PanelGroup>\n </div>\n );\n\n await expectTemplate(handle.current, \"343px 10px 147px\");\n });\n});\n\ntest(\"Keyboard interactions with collapsed panels\", async () => {\n const handle = { current: null } as unknown as {\n current: PanelGroupHandle;\n };\n const rightHandle = { current: null } as unknown as {\n current: PanelHandle;\n };\n render(\n <div style={{ width: 500 }}>\n <Collapsible handle={handle} rightPanelHandle={rightHandle} />\n </div>\n );\n\n await waitForMeasurement(handle.current);\n await expectTemplate(handle.current, \"209px 10px 209px 10px 60px\");\n\n const resizer2 = document.getElementById(\"resizer-2\")!;\n fireEvent.keyDown(resizer2, { key: \"Enter\" });\n await expectTemplate(\n handle.current,\n \"209px 10px 168.953125px 10px 100.03125px\"\n );\n\n fireEvent.keyDown(resizer2, { key: \"ArrowLeft\" });\n fireEvent.keyDown(resizer2, { key: \"ArrowLeft\" });\n fireEvent.keyDown(resizer2, { key: \"ArrowLeft\" });\n fireEvent.keyDown(resizer2, { key: \"ArrowLeft\" });\n await expectTemplate(\n handle.current,\n \"209px 10px 164.96875px 10px 104.03125px\"\n );\n\n fireEvent.keyDown(resizer2, { key: \"ArrowLeft\", shiftKey: true });\n await expectTemplate(\n handle.current,\n \"209px 10px 149.96875px 10px 119.03125px\"\n );\n\n fireEvent.keyDown(resizer2, { key: \"Enter\" });\n await expectTemplate(handle.current, \"209px 10px 209px 10px 60px\");\n\n fireEvent.keyDown(resizer2, { key: \"Enter\" });\n await expectTemplate(\n handle.current,\n \"209px 10px 149.96875px 10px 119.03125px\"\n );\n});\n\ndescribe(\"imperative panel API\", async () => {\n test(\"panel group\", async () => {\n const handle = { current: null } as unknown as {\n current: PanelGroupHandle;\n };\n\n render(\n <div style={{ width: 500 }}>\n <Collapsible handle={handle} />\n </div>\n );\n\n await waitForMeasurement(handle.current);\n\n expect(handle.current.getPercentageSizes()).toMatchInlineSnapshot(`\n [\n 0.5,\n 0.020080321285140562,\n 0.5,\n 0.020080321285140562,\n 0.12048192771084337,\n ]\n `);\n\n expect(handle.current.getPixelSizes()).toMatchInlineSnapshot(`\n [\n 209,\n 10,\n 209,\n 10,\n 60,\n ]\n `);\n\n await expectTemplate(handle.current, \"209px 10px 209px 10px 60px\");\n });\n\n test(\"panel\", async () => {\n const handle = { current: null } as unknown as {\n current: PanelGroupHandle;\n };\n const rightHandle = { current: null } as unknown as {\n current: PanelHandle;\n };\n const leftHandle = { current: null } as unknown as {\n current: PanelHandle;\n };\n\n render(\n <div style={{ width: 500 }}>\n <Collapsible\n handle={handle}\n leftPanelHandle={leftHandle}\n rightPanelHandle={rightHandle}\n />\n </div>\n );\n\n await waitForMeasurement(handle.current);\n\n expect(rightHandle.current.isCollapsed()).toBe(true);\n expect(rightHandle.current.isExpanded()).toBe(false);\n\n rightHandle.current.expand();\n await new Promise((resolve) => setTimeout(resolve, 2000));\n\n expect(rightHandle.current.isCollapsed()).toBe(false);\n expect(rightHandle.current.isExpanded()).toBe(true);\n\n rightHandle.current.collapse();\n await new Promise((resolve) => setTimeout(resolve, 2000));\n\n expect(rightHandle.current.isCollapsed()).toBe(true);\n expect(rightHandle.current.isExpanded()).toBe(false);\n\n // Test the non controlled version\n\n expect(leftHandle.current.isCollapsed()).toBe(false);\n expect(leftHandle.current.isExpanded()).toBe(true);\n\n leftHandle.current.collapse();\n await new Promise((resolve) => setTimeout(resolve, 2000));\n\n expect(leftHandle.current.isCollapsed()).toBe(true);\n expect(leftHandle.current.isExpanded()).toBe(false);\n expect(rightHandle.current.getPercentageSize()).toBe(\n leftHandle.current.getPercentageSize()\n );\n expect(rightHandle.current.getPixelSize()).toBe(\n leftHandle.current.getPixelSize()\n );\n\n leftHandle.current.expand();\n await new Promise((resolve) => setTimeout(resolve, 5000));\n\n expect(leftHandle.current.isCollapsed()).toBe(false);\n expect(leftHandle.current.isExpanded()).toBe(true);\n });\n});\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=bundle.size.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bundle.size.d.ts","sourceRoot":"","sources":["../../src/bundle.size.ts"],"names":[],"mappings":""}
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ const windowSplitter = __importStar(require("./ReactWindowSplitter.js"));
27
+ // eslint-disable-next-line no-console
28
+ console.log(windowSplitter);
29
+ //# sourceMappingURL=bundle.size.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bundle.size.js","sourceRoot":"","sources":["../../src/bundle.size.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yEAA2D;AAE3D,sCAAsC;AACtC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC","sourcesContent":["import * as windowSplitter from \"./ReactWindowSplitter.js\";\n\n// eslint-disable-next-line no-console\nconsole.log(windowSplitter);\n"]}
@@ -0,0 +1,3 @@
1
+ export * from "./ReactWindowSplitter.js";
2
+ export { PanelHandle, PanelGroupHandle } from "@window-splitter/interface";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./ReactWindowSplitter.js"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2DAAyC","sourcesContent":["export * from \"./ReactWindowSplitter.js\";\nexport { PanelHandle, PanelGroupHandle } from \"@window-splitter/interface\";\n"]}
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "commonjs"
3
+ }
@@ -0,0 +1,8 @@
1
+ import * as React from "react";
2
+ /** Returns the index path data based on the closest useIndexedChildren. */
3
+ export declare function useIndex(): {
4
+ index: number;
5
+ };
6
+ /** Provides the current index path for each child. */
7
+ export declare function useIndexedChildren(childrenProp: React.ReactNode): React.JSX.Element;
8
+ //# sourceMappingURL=useIndexedChildren.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useIndexedChildren.d.ts","sourceRoot":"","sources":["../../src/useIndexedChildren.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAc/B,2EAA2E;AAC3E,wBAAgB,QAAQ;;EAWvB;AAwBD,sDAAsD;AACtD,wBAAgB,kBAAkB,CAAC,YAAY,EAAE,KAAK,CAAC,SAAS,qBAyB/D"}
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ // File largely copied from https://github.com/souporserious/reforest
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || function (mod) {
20
+ if (mod && mod.__esModule) return mod;
21
+ var result = {};
22
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
23
+ __setModuleDefault(result, mod);
24
+ return result;
25
+ };
26
+ Object.defineProperty(exports, "__esModule", { value: true });
27
+ exports.useIndex = useIndex;
28
+ exports.useIndexedChildren = useIndexedChildren;
29
+ const React = __importStar(require("react"));
30
+ const IndexContext = React.createContext(null);
31
+ /**
32
+ * Parses a numerical dot-separated string as an index path.
33
+ *
34
+ * @example
35
+ * parseIndexPath('0.10.2') -> [0, 10, 2]
36
+ */
37
+ function parseIndexPath(indexPathString) {
38
+ return indexPathString.split(".").map((index) => parseInt(index, 10));
39
+ }
40
+ /** Returns the index path data based on the closest useIndexedChildren. */
41
+ function useIndex() {
42
+ const indexPathString = React.useContext(IndexContext);
43
+ return React.useMemo(() => {
44
+ if (indexPathString === null) {
45
+ throw new Error("Panels/PanelResizers must be used within a PanelGroup");
46
+ }
47
+ const indexPath = parseIndexPath(indexPathString);
48
+ return { index: indexPath[indexPath.length - 1] };
49
+ }, [indexPathString]);
50
+ }
51
+ function flattenChildren(children) {
52
+ const flattenedChildren = children.flatMap((child) => {
53
+ // For fragments we want to get rid of those so the children are flat
54
+ if (React.isValidElement(child) && child.type === React.Fragment) {
55
+ return flattenChildren(child.props.children);
56
+ }
57
+ return child;
58
+ });
59
+ return flattenedChildren.map((child, index) => {
60
+ if (!React.isValidElement(child))
61
+ return child;
62
+ // We then correct the keys for the order of the children
63
+ // eslint-disable-next-line @eslint-react/no-clone-element
64
+ return React.cloneElement(child, {
65
+ // eslint-disable-next-line @eslint-react/no-array-index-key
66
+ key: `.${index}`,
67
+ });
68
+ });
69
+ }
70
+ /** Provides the current index path for each child. */
71
+ function useIndexedChildren(childrenProp) {
72
+ const indexPathString = React.useContext(IndexContext);
73
+ return (React.createElement(React.Fragment, null, flattenChildren(React.Children.toArray(childrenProp)).map((child, index) => {
74
+ if (!React.isValidElement(child))
75
+ return child;
76
+ return (React.createElement(IndexContext.Provider, { key: child.key, value: indexPathString
77
+ ? `${indexPathString}.${index.toString()}`
78
+ : index.toString() }, child));
79
+ })));
80
+ }
81
+ //# sourceMappingURL=useIndexedChildren.js.map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AC;QAED,OAAO,KAAK,CAAC;IACf,CAAC,CAAC,CAAC;IAEH,OAAO,iBAAiB,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;QAC5C,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC;YAAE,OAAO,KAAK,CAAC;QAE/C,yDAAyD;QACzD,0DAA0D;QAC1D,OAAO,KAAK,CAAC,YAAY,CAAC,KAAK,EAAE;YAC/B,4DAA4D;YAC5D,GAAG,EAAE,IAAI,KAAK,EAAE;SACjB,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAED,sDAAsD;AACtD,SAAgB,kBAAkB,CAAC,YAA6B;IAC9D,MAAM,eAAe,GAAG,KAAK,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;IAEvD,OAAO,CACL,0CAEG,eAAe,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,GAAG,CACxD,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;QACf,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC;YAAE,OAAO,KAAK,CAAC;QAC/C,OAAO,CACL,oBAAC,YAAY,CAAC,QAAQ,IACpB,GAAG,EAAE,KAAK,CAAC,GAAG,EACd,KAAK,EACH,eAAe;gBACb,CAAC,CAAC,GAAG,eAAe,IAAI,KAAK,CAAC,QAAQ,EAAE,EAAE;gBAC1C,CAAC,CAAC,KAAK,CAAC,QAAQ,EAAE,IAGrB,KAAK,CACgB,CACzB,CAAC;IACJ,CAAC,CACF,CACA,CACJ,CAAC;AACJ,CAAC","sourcesContent":["// File largely copied from https://github.com/souporserious/reforest\n\nimport * as React from \"react\";\n\nconst IndexContext = React.createContext<string | null>(null);\n\n/**\n * Parses a numerical dot-separated string as an index path.\n *\n * @example\n * parseIndexPath('0.10.2') -> [0, 10, 2]\n */\nfunction parseIndexPath(indexPathString: string) {\n return indexPathString.split(\".\").map((index) => parseInt(index, 10));\n}\n\n/** Returns the index path data based on the closest useIndexedChildren. */\nexport function useIndex() {\n const indexPathString = React.useContext(IndexContext);\n\n return React.useMemo(() => {\n if (indexPathString === null) {\n throw new Error(\"Panels/PanelResizers must be used within a PanelGroup\");\n }\n\n const indexPath = parseIndexPath(indexPathString);\n return { index: indexPath[indexPath.length - 1]! };\n }, [indexPathString]);\n}\n\nfunction flattenChildren(children: React.ReactNode[]): React.ReactNode[] {\n const flattenedChildren = children.flatMap((child) => {\n // For fragments we want to get rid of those so the children are flat\n if (React.isValidElement(child) && child.type === React.Fragment) {\n return flattenChildren(child.props.children);\n }\n\n return child;\n });\n\n return flattenedChildren.map((child, index) => {\n if (!React.isValidElement(child)) return child;\n\n // We then correct the keys for the order of the children\n // eslint-disable-next-line @eslint-react/no-clone-element\n return React.cloneElement(child, {\n // eslint-disable-next-line @eslint-react/no-array-index-key\n key: `.${index}`,\n });\n });\n}\n\n/** Provides the current index path for each child. */\nexport function useIndexedChildren(childrenProp: React.ReactNode) {\n const indexPathString = React.useContext(IndexContext);\n\n return (\n <>\n {/* eslint-disable-next-line @eslint-react/no-children-to-array */}\n {flattenChildren(React.Children.toArray(childrenProp)).map(\n (child, index) => {\n if (!React.isValidElement(child)) return child;\n return (\n <IndexContext.Provider\n key={child.key}\n value={\n indexPathString\n ? `${indexPathString}.${index.toString()}`\n : index.toString()\n }\n >\n {child}\n </IndexContext.Provider>\n );\n }\n )}\n </>\n );\n}\n"]}
@@ -0,0 +1,8 @@
1
+ import { MoveEvents } from "@window-splitter/interface";
2
+ export declare function useMove({ onMoveStart, onMove, onMoveEnd }: MoveEvents): {
3
+ moveProps: {
4
+ onPointerDown: (e: React.PointerEvent) => void;
5
+ onKeyDown: (e: React.KeyboardEvent) => void;
6
+ };
7
+ };
8
+ //# sourceMappingURL=useMove.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useMove.d.ts","sourceRoot":"","sources":["../../src/useMove.ts"],"names":[],"mappings":"AACA,OAAO,EAAQ,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAG9D,wBAAgB,OAAO,CAAC,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,UAAU;eAWrD;QACT,aAAa,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,YAAY,KAAK,IAAI,CAAC;QAC/C,SAAS,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,aAAa,KAAK,IAAI,CAAC;KAC7C;EAGN"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useMove = useMove;
4
+ const utils_1 = require("@react-aria/utils");
5
+ const interface_1 = require("@window-splitter/interface");
6
+ const react_1 = require("react");
7
+ function useMove({ onMoveStart, onMove, onMoveEnd }) {
8
+ const onMoveStartEvent = (0, utils_1.useEffectEvent)(onMoveStart);
9
+ const onMoveEvent = (0, utils_1.useEffectEvent)(onMove);
10
+ const onMoveEndEvent = (0, utils_1.useEffectEvent)(onMoveEnd);
11
+ return (0, react_1.useMemo)(() => {
12
+ return (0, interface_1.move)({
13
+ onMoveStart: onMoveStartEvent,
14
+ onMove: onMoveEvent,
15
+ onMoveEnd: onMoveEndEvent,
16
+ });
17
+ }, [onMoveStartEvent, onMoveEvent, onMoveEndEvent]);
18
+ }
19
+ //# sourceMappingURL=useMove.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useMove.js","sourceRoot":"","sources":["../../src/useMove.ts"],"names":[],"mappings":";;AAIA,0BAiBC;AArBD,6CAAmD;AACnD,0DAA8D;AAC9D,iCAAgC;AAEhC,SAAgB,OAAO,CAAC,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAc;IACpE,MAAM,gBAAgB,GAAG,IAAA,sBAAc,EAAC,WAAW,CAAC,CAAC;IACrD,MAAM,WAAW,GAAG,IAAA,sBAAc,EAAC,MAAM,CAAC,CAAC;IAC3C,MAAM,cAAc,GAAG,IAAA,sBAAc,EAAC,SAAS,CAAC,CAAC;IAEjD,OAAO,IAAA,eAAO,EAAC,GAAG,EAAE;QAClB,OAAO,IAAA,gBAAI,EAAC;YACV,WAAW,EAAE,gBAAgB;YAC7B,MAAM,EAAE,WAAW;YACnB,SAAS,EAAE,cAAc;SAC1B,CAKA,CAAC;IACJ,CAAC,EAAE,CAAC,gBAAgB,EAAE,WAAW,EAAE,cAAc,CAAC,CAAC,CAAC;AACtD,CAAC","sourcesContent":["import { useEffectEvent } from \"@react-aria/utils\";\nimport { move, MoveEvents } from \"@window-splitter/interface\";\nimport { useMemo } from \"react\";\n\nexport function useMove({ onMoveStart, onMove, onMoveEnd }: MoveEvents) {\n const onMoveStartEvent = useEffectEvent(onMoveStart);\n const onMoveEvent = useEffectEvent(onMove);\n const onMoveEndEvent = useEffectEvent(onMoveEnd);\n\n return useMemo(() => {\n return move({\n onMoveStart: onMoveStartEvent,\n onMove: onMoveEvent,\n onMoveEnd: onMoveEndEvent,\n }) as unknown as {\n moveProps: {\n onPointerDown: (e: React.PointerEvent) => void;\n onKeyDown: (e: React.KeyboardEvent) => void;\n };\n };\n }, [onMoveStartEvent, onMoveEvent, onMoveEndEvent]);\n}\n"]}
@@ -0,0 +1,19 @@
1
+ import { PanelGroupHandle, PanelHandle, SharedPanelGroupProps, SharedPanelProps, SharedPanelResizerProps } from "@window-splitter/interface";
2
+ import React from "react";
3
+ export interface PanelGroupProps extends React.HTMLAttributes<HTMLDivElement>, SharedPanelGroupProps {
4
+ /** Imperative handle to control the group */
5
+ handle?: React.Ref<PanelGroupHandle>;
6
+ }
7
+ /** A group of panels that has constraints and a user can resize */
8
+ export declare const PanelGroup: React.ForwardRefExoticComponent<PanelGroupProps & React.RefAttributes<HTMLDivElement>>;
9
+ export interface PanelProps extends SharedPanelProps<boolean>, Omit<React.HTMLAttributes<HTMLDivElement>, "onResize"> {
10
+ /** Imperative handle to control the panel */
11
+ handle?: React.Ref<PanelHandle>;
12
+ }
13
+ /** A panel within a `PanelGroup` */
14
+ export declare const Panel: React.ForwardRefExoticComponent<PanelProps & React.RefAttributes<HTMLDivElement>>;
15
+ export interface PanelResizerProps extends SharedPanelResizerProps, Omit<React.HTMLAttributes<HTMLDivElement>, "onDragStart" | "onDrag" | "onDragEnd"> {
16
+ }
17
+ /** A resize handle to place between panels. */
18
+ export declare const PanelResizer: React.ForwardRefExoticComponent<PanelResizerProps & React.RefAttributes<HTMLDivElement>>;
19
+ //# sourceMappingURL=ReactWindowSplitter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ReactWindowSplitter.d.ts","sourceRoot":"","sources":["../../src/ReactWindowSplitter.tsx"],"names":[],"mappings":"AAEA,OAAO,EAIL,gBAAgB,EAChB,WAAW,EACX,qBAAqB,EACrB,gBAAgB,EAChB,uBAAuB,EAExB,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAQN,MAAM,OAAO,CAAC;AA+If,MAAM,WAAW,eACf,SAAQ,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC,EAC1C,qBAAqB;IACvB,6CAA6C;IAC7C,MAAM,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;CACtC;AA4ID,mEAAmE;AACnE,eAAO,MAAM,UAAU,wFAoBtB,CAAC;AA0KF,MAAM,WAAW,UACf,SAAQ,gBAAgB,CAAC,OAAO,CAAC,EAC/B,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,UAAU,CAAC;IACxD,6CAA6C;IAC7C,MAAM,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;CACjC;AAED,oCAAoC;AACpC,eAAO,MAAM,KAAK,mFAqEjB,CAAC;AAgIF,MAAM,WAAW,iBACf,SAAQ,uBAAuB,EAC7B,IAAI,CACF,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC,EACpC,aAAa,GAAG,QAAQ,GAAG,WAAW,CACvC;CAAG;AAER,+CAA+C;AAC/C,eAAO,MAAM,YAAY,0FAqBxB,CAAC"}