@window-splitter/solid 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.
- package/.storybook/main.ts +24 -0
- package/.storybook/preview.ts +14 -0
- package/.tshy/build.json +8 -0
- package/.tshy/esm.json +18 -0
- package/.turbo/turbo-build.log +5 -0
- package/.turbo/turbo-lint.log +5 -0
- package/CHANGELOG.md +66 -0
- package/README.md +54 -0
- package/dist/esm/SolidWIndowSplitter.d.ts +19 -0
- package/dist/esm/SolidWIndowSplitter.d.ts.map +1 -0
- package/dist/esm/SolidWIndowSplitter.jsx +506 -0
- package/dist/esm/SolidWIndowSplitter.jsx.map +1 -0
- package/dist/esm/SolidWindowSplitter.stories.d.ts +52 -0
- package/dist/esm/SolidWindowSplitter.stories.d.ts.map +1 -0
- package/dist/esm/SolidWindowSplitter.stories.jsx +470 -0
- package/dist/esm/SolidWindowSplitter.stories.jsx.map +1 -0
- package/dist/esm/SolidWindowSplitter.test.d.ts +2 -0
- package/dist/esm/SolidWindowSplitter.test.d.ts.map +1 -0
- package/dist/esm/SolidWindowSplitter.test.jsx +197 -0
- package/dist/esm/SolidWindowSplitter.test.jsx.map +1 -0
- package/dist/esm/context.d.ts +18 -0
- package/dist/esm/context.d.ts.map +1 -0
- package/dist/esm/context.jsx +38 -0
- package/dist/esm/context.jsx.map +1 -0
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/mergeSolidAttributes.d.ts +6 -0
- package/dist/esm/mergeSolidAttributes.d.ts.map +1 -0
- package/dist/esm/mergeSolidAttributes.js +45 -0
- package/dist/esm/mergeSolidAttributes.js.map +1 -0
- package/dist/esm/package.json +3 -0
- package/doctor-storybook.log +29 -0
- package/eslint.config.js +10 -0
- package/index.html +11 -0
- package/package.json +104 -0
- package/rsbuild.config.js +25 -0
- package/src/SolidWIndowSplitter.tsx +683 -0
- package/src/SolidWindowSplitter.stories.tsx +689 -0
- package/src/SolidWindowSplitter.test.tsx +333 -0
- package/src/__snapshots__/SolidWindowSplitter.test.tsx.snap +56 -0
- package/src/context.tsx +58 -0
- package/src/index.ts +1 -0
- package/src/mergeSolidAttributes.ts +61 -0
- package/tsconfig.json +8 -0
- package/vite.config.js +6 -0
- package/vitest.config.ts +22 -0
|
@@ -0,0 +1,689 @@
|
|
|
1
|
+
import type { Meta } from "storybook-solidjs";
|
|
2
|
+
import { spring } from "framer-motion";
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
PanelGroup,
|
|
6
|
+
PanelResizer,
|
|
7
|
+
Panel,
|
|
8
|
+
PanelGroupProps,
|
|
9
|
+
PanelProps,
|
|
10
|
+
PanelResizerProps,
|
|
11
|
+
} from "./SolidWIndowSplitter.jsx";
|
|
12
|
+
import { createSignal, Ref, Show, splitProps } from "solid-js";
|
|
13
|
+
import { PanelHandle } from "@window-splitter/interface";
|
|
14
|
+
import { PanelGroupHandle } from "@window-splitter/interface";
|
|
15
|
+
import { GroupMachineContextValue } from "@window-splitter/state";
|
|
16
|
+
|
|
17
|
+
const meta = {
|
|
18
|
+
title: "Components/Solid",
|
|
19
|
+
component: PanelGroup,
|
|
20
|
+
} satisfies Meta<typeof PanelGroup>;
|
|
21
|
+
|
|
22
|
+
export default meta;
|
|
23
|
+
|
|
24
|
+
function StyledPanelGroup(props: PanelGroupProps) {
|
|
25
|
+
return (
|
|
26
|
+
<PanelGroup
|
|
27
|
+
{...props}
|
|
28
|
+
style={{
|
|
29
|
+
border: "1px solid rgba(0, 0, 0, 0.3)",
|
|
30
|
+
background: "rgba(0, 0, 0, 0.1)",
|
|
31
|
+
"border-radius": "12px",
|
|
32
|
+
"box-sizing": "border-box",
|
|
33
|
+
...props.style,
|
|
34
|
+
}}
|
|
35
|
+
/>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function StyledPanel(props: PanelProps) {
|
|
40
|
+
const [, attrs] = splitProps(props, ["children"]);
|
|
41
|
+
return (
|
|
42
|
+
<Panel
|
|
43
|
+
style={{
|
|
44
|
+
overflow: "hidden",
|
|
45
|
+
}}
|
|
46
|
+
{...attrs}
|
|
47
|
+
>
|
|
48
|
+
<div
|
|
49
|
+
style={{
|
|
50
|
+
height: "100%",
|
|
51
|
+
width: "100%",
|
|
52
|
+
padding: "20px",
|
|
53
|
+
display: "flex",
|
|
54
|
+
"align-items": "center",
|
|
55
|
+
"justify-content": "center",
|
|
56
|
+
overflow: "hidden",
|
|
57
|
+
"box-sizing": "border-box",
|
|
58
|
+
}}
|
|
59
|
+
>
|
|
60
|
+
{props.children}
|
|
61
|
+
</div>
|
|
62
|
+
</Panel>
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function StyledResizer(props: PanelResizerProps) {
|
|
67
|
+
return <PanelResizer size="10px" style={{ background: "red" }} {...props} />;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function Simple(props: { handle?: Ref<PanelGroupHandle> }) {
|
|
71
|
+
return (
|
|
72
|
+
<StyledPanelGroup handle={props.handle} style={{ height: "200px" }}>
|
|
73
|
+
<StyledPanel>Panel 1</StyledPanel>
|
|
74
|
+
<StyledResizer />
|
|
75
|
+
<StyledPanel min="100px">Panel 2</StyledPanel>
|
|
76
|
+
</StyledPanelGroup>
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export function Autosave(props: {
|
|
81
|
+
handle?: Ref<PanelGroupHandle>;
|
|
82
|
+
snapshot?: GroupMachineContextValue;
|
|
83
|
+
}) {
|
|
84
|
+
return (
|
|
85
|
+
<StyledPanelGroup
|
|
86
|
+
autosaveId="autosave-example-solid"
|
|
87
|
+
handle={props.handle}
|
|
88
|
+
snapshot={props.snapshot}
|
|
89
|
+
>
|
|
90
|
+
<StyledPanel id="1">Panel 1</StyledPanel>
|
|
91
|
+
<StyledResizer id="resizer" />
|
|
92
|
+
<StyledPanel id="2">Panel 2</StyledPanel>
|
|
93
|
+
</StyledPanelGroup>
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export function AutosaveCookie(props: {
|
|
98
|
+
handle?: Ref<PanelGroupHandle>;
|
|
99
|
+
snapshot?: GroupMachineContextValue;
|
|
100
|
+
}) {
|
|
101
|
+
return (
|
|
102
|
+
<StyledPanelGroup
|
|
103
|
+
autosaveId="autosave-cookie-solid"
|
|
104
|
+
autosaveStrategy="cookie"
|
|
105
|
+
style={{ height: "200px" }}
|
|
106
|
+
handle={props.handle}
|
|
107
|
+
snapshot={props.snapshot}
|
|
108
|
+
>
|
|
109
|
+
<StyledPanel id="1">Panel 1</StyledPanel>
|
|
110
|
+
<StyledResizer id="resizer1" size="10px" style={{ background: "red" }} />
|
|
111
|
+
<StyledPanel id="2">Panel 2</StyledPanel>
|
|
112
|
+
</StyledPanelGroup>
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export function AutosaveCollapsible(props: {
|
|
117
|
+
handle?: Ref<PanelGroupHandle>;
|
|
118
|
+
onCollapseChange?: (isCollapsed: boolean) => void;
|
|
119
|
+
}) {
|
|
120
|
+
return (
|
|
121
|
+
<StyledPanelGroup autosaveId="autosave-example-2" handle={props.handle}>
|
|
122
|
+
<StyledPanel
|
|
123
|
+
id="1"
|
|
124
|
+
collapsible
|
|
125
|
+
collapsedSize="100px"
|
|
126
|
+
min="140px"
|
|
127
|
+
onCollapseChange={props.onCollapseChange}
|
|
128
|
+
>
|
|
129
|
+
Collapsible
|
|
130
|
+
</StyledPanel>
|
|
131
|
+
<StyledResizer id="resizer" />
|
|
132
|
+
<StyledPanel id="2">Panel 2</StyledPanel>
|
|
133
|
+
</StyledPanelGroup>
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// TODO: fix this
|
|
138
|
+
export function DynamicConstraints(props: { handle?: Ref<PanelGroupHandle> }) {
|
|
139
|
+
const [customOn, setCustomOn] = createSignal(false);
|
|
140
|
+
|
|
141
|
+
return (
|
|
142
|
+
<>
|
|
143
|
+
<StyledPanelGroup handle={props.handle}>
|
|
144
|
+
<StyledPanel default="100px" min={customOn() ? "200px" : "100px"}>
|
|
145
|
+
<div>Panel 1</div>
|
|
146
|
+
</StyledPanel>
|
|
147
|
+
<StyledResizer />
|
|
148
|
+
<StyledPanel min="100px">
|
|
149
|
+
<div>Panel 2</div>
|
|
150
|
+
</StyledPanel>
|
|
151
|
+
<StyledResizer />
|
|
152
|
+
<StyledPanel
|
|
153
|
+
min={customOn() ? "100px" : "400px"}
|
|
154
|
+
max={customOn() ? "300px" : "700px"}
|
|
155
|
+
>
|
|
156
|
+
<div>Panel 3</div>
|
|
157
|
+
</StyledPanel>
|
|
158
|
+
</StyledPanelGroup>
|
|
159
|
+
<button type="button" onClick={() => setCustomOn(!customOn())}>
|
|
160
|
+
Toggle Custom
|
|
161
|
+
</button>
|
|
162
|
+
</>
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export function SimpleMin() {
|
|
167
|
+
return (
|
|
168
|
+
<StyledPanelGroup>
|
|
169
|
+
<StyledPanel min="100px">
|
|
170
|
+
<div>Panel 1</div>
|
|
171
|
+
</StyledPanel>
|
|
172
|
+
<StyledResizer />
|
|
173
|
+
<StyledPanel min="100px">
|
|
174
|
+
<div>Panel 2</div>
|
|
175
|
+
</StyledPanel>
|
|
176
|
+
<StyledResizer />
|
|
177
|
+
<StyledPanel min="100px">
|
|
178
|
+
<div>Panel 3</div>
|
|
179
|
+
</StyledPanel>
|
|
180
|
+
</StyledPanelGroup>
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export function SimpleMinMax() {
|
|
185
|
+
return (
|
|
186
|
+
<StyledPanelGroup>
|
|
187
|
+
<StyledPanel min="100px" max="200px">
|
|
188
|
+
<div>Panel 1</div>
|
|
189
|
+
</StyledPanel>
|
|
190
|
+
<StyledResizer />
|
|
191
|
+
<StyledPanel min="100px">
|
|
192
|
+
<div>Panel 2</div>
|
|
193
|
+
</StyledPanel>
|
|
194
|
+
<StyledResizer size="20px" />
|
|
195
|
+
<StyledPanel min="100px">
|
|
196
|
+
<div>Panel 3</div>
|
|
197
|
+
</StyledPanel>
|
|
198
|
+
</StyledPanelGroup>
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export function SimpleConstraints() {
|
|
203
|
+
return (
|
|
204
|
+
<StyledPanelGroup>
|
|
205
|
+
<StyledPanel min="100px" max="50%">
|
|
206
|
+
<div>Panel 1</div>
|
|
207
|
+
</StyledPanel>
|
|
208
|
+
<StyledResizer />
|
|
209
|
+
<StyledPanel>
|
|
210
|
+
<div>Panel 2</div>
|
|
211
|
+
</StyledPanel>
|
|
212
|
+
</StyledPanelGroup>
|
|
213
|
+
);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
export function HorizontalLayout() {
|
|
217
|
+
return (
|
|
218
|
+
<StyledPanelGroup orientation="horizontal">
|
|
219
|
+
<StyledPanel default="30%" min="20%">
|
|
220
|
+
left
|
|
221
|
+
</StyledPanel>
|
|
222
|
+
<StyledResizer />
|
|
223
|
+
<StyledPanel min="20%">middle</StyledPanel>
|
|
224
|
+
<StyledResizer />
|
|
225
|
+
<StyledPanel default="30%" min="20%">
|
|
226
|
+
right
|
|
227
|
+
</StyledPanel>
|
|
228
|
+
</StyledPanelGroup>
|
|
229
|
+
);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
export function VerticalLayout(props: { handle?: Ref<PanelGroupHandle> }) {
|
|
233
|
+
return (
|
|
234
|
+
<StyledPanelGroup
|
|
235
|
+
orientation="vertical"
|
|
236
|
+
style={{ height: "322px" }}
|
|
237
|
+
handle={props.handle}
|
|
238
|
+
>
|
|
239
|
+
<StyledPanel default="30%" min="20%">
|
|
240
|
+
top
|
|
241
|
+
</StyledPanel>
|
|
242
|
+
<StyledResizer />
|
|
243
|
+
<StyledPanel min="20%">middle</StyledPanel>
|
|
244
|
+
<StyledResizer />
|
|
245
|
+
<StyledPanel default="30%" min="20%">
|
|
246
|
+
bottom
|
|
247
|
+
</StyledPanel>
|
|
248
|
+
</StyledPanelGroup>
|
|
249
|
+
);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
export function VerticalLayout2() {
|
|
253
|
+
return (
|
|
254
|
+
<StyledPanelGroup
|
|
255
|
+
orientation="vertical"
|
|
256
|
+
style={{ height: "calc(100vh - 100px)" }}
|
|
257
|
+
>
|
|
258
|
+
<StyledPanel default="200px" min="200px">
|
|
259
|
+
top
|
|
260
|
+
</StyledPanel>
|
|
261
|
+
<StyledResizer />
|
|
262
|
+
<StyledPanel
|
|
263
|
+
min="200px"
|
|
264
|
+
collapsedSize="60px"
|
|
265
|
+
defaultCollapsed
|
|
266
|
+
collapsible
|
|
267
|
+
>
|
|
268
|
+
middle
|
|
269
|
+
</StyledPanel>
|
|
270
|
+
</StyledPanelGroup>
|
|
271
|
+
);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
export function NestedGroups() {
|
|
275
|
+
return (
|
|
276
|
+
<PanelGroup
|
|
277
|
+
orientation="horizontal"
|
|
278
|
+
style={{
|
|
279
|
+
border: "1px solid rgba(0, 0, 0, 0.3)",
|
|
280
|
+
"border-radius": "12px",
|
|
281
|
+
height: "400px",
|
|
282
|
+
}}
|
|
283
|
+
>
|
|
284
|
+
<Panel min="10%">1</Panel>
|
|
285
|
+
<StyledResizer />
|
|
286
|
+
<Panel min="10%">
|
|
287
|
+
<PanelGroup orientation="vertical">
|
|
288
|
+
<Panel min="10%">2-1</Panel>
|
|
289
|
+
<StyledResizer />
|
|
290
|
+
<Panel min="10%">
|
|
291
|
+
<PanelGroup orientation="horizontal">
|
|
292
|
+
<Panel min="20%">2-2-1</Panel>
|
|
293
|
+
<StyledResizer />
|
|
294
|
+
<Panel min="20%">2-2-2</Panel>
|
|
295
|
+
</PanelGroup>
|
|
296
|
+
</Panel>
|
|
297
|
+
</PanelGroup>
|
|
298
|
+
</Panel>
|
|
299
|
+
<StyledResizer />
|
|
300
|
+
<Panel min="10%">3</Panel>
|
|
301
|
+
</PanelGroup>
|
|
302
|
+
);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
export function WithOverflow() {
|
|
306
|
+
return (
|
|
307
|
+
<StyledPanelGroup style={{ height: "400px" }}>
|
|
308
|
+
<Panel min="200px">
|
|
309
|
+
<div
|
|
310
|
+
style={{
|
|
311
|
+
overflow: "auto",
|
|
312
|
+
padding: "40px",
|
|
313
|
+
height: "100%",
|
|
314
|
+
"box-sizing": "border-box",
|
|
315
|
+
}}
|
|
316
|
+
>
|
|
317
|
+
<p>
|
|
318
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec
|
|
319
|
+
euismod, nisl eget ultricies ultrices, nunc nisi aliquam nisi, eu
|
|
320
|
+
tincidunt nisl nisl eu nisl. Sed euismod, nisl eget ultricies
|
|
321
|
+
ultrices, nunc nisi aliquam nisi, eu tincidunt nisl nisl eu nisl.
|
|
322
|
+
Sed euismod, nisl eget ultricies ultrices, nunc nisi aliquam nisi,
|
|
323
|
+
eu tincidunt nisl nisl eu nisl.
|
|
324
|
+
</p>
|
|
325
|
+
<p>
|
|
326
|
+
Sed euismod, nisl eget ultricies ultrices, nunc nisi aliquam nisi,
|
|
327
|
+
eu tincidunt nisl nisl eu nisl. Sed euismod, nisl eget ultricies
|
|
328
|
+
ultrices, nunc nisi aliquam nisi, eu tincidunt nisl nisl eu nisl.
|
|
329
|
+
Sed euismod, nisl eget ultricies ultrices, nunc nisi aliquam nisi,
|
|
330
|
+
eu tincidunt nisl nisl eu nisl.
|
|
331
|
+
</p>
|
|
332
|
+
<p>
|
|
333
|
+
Sed euismod, nisl eget ultricies ultrices, nunc nisi aliquam nisi,
|
|
334
|
+
eu tincidunt nisl nisl eu nisl. Sed euismod, nisl eget ultricies
|
|
335
|
+
ultrices, nunc nisi aliquam nisi, eu tincidunt nisl nisl eu nisl.
|
|
336
|
+
Sed euismod, nisl eget ultricies ultrices, nunc nisi aliquam nisi,
|
|
337
|
+
eu tincidunt nisl nisl eu nisl.
|
|
338
|
+
</p>
|
|
339
|
+
<p>
|
|
340
|
+
Sed euismod, nisl eget ultricies ultrices, nunc nisi aliquam nisi,
|
|
341
|
+
eu tincidunt nisl nisl eu nisl. Sed euismod, nisl eget ultricies
|
|
342
|
+
ultrices, nunc nisi aliquam nisi, eu tincidunt nisl nisl eu nisl.
|
|
343
|
+
Sed euismod, nisl eget ultricies ultrices, nunc nisi aliquam nisi,
|
|
344
|
+
eu tincidunt nisl nisl eu nisl.
|
|
345
|
+
</p>
|
|
346
|
+
<p>
|
|
347
|
+
Sed euismod, nisl eget ultricies ultrices, nunc nisi aliquam nisi,
|
|
348
|
+
eu tincidunt nisl nisl eu nisl. Sed euismod, nisl eget ultricies
|
|
349
|
+
ultrices, nunc nisi aliquam nisi, eu tincidunt nisl nisl eu nisl.
|
|
350
|
+
Sed euismod, nisl eget ultricies ultrices, nunc nisi aliquam nisi,
|
|
351
|
+
eu tincidunt nisl nisl eu nisl.
|
|
352
|
+
</p>
|
|
353
|
+
</div>
|
|
354
|
+
</Panel>
|
|
355
|
+
<StyledResizer />
|
|
356
|
+
<Panel min="200px">
|
|
357
|
+
<div
|
|
358
|
+
style={{
|
|
359
|
+
overflow: "auto",
|
|
360
|
+
padding: "40px",
|
|
361
|
+
height: "100%",
|
|
362
|
+
"box-sizing": "border-box",
|
|
363
|
+
}}
|
|
364
|
+
>
|
|
365
|
+
<p>
|
|
366
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec
|
|
367
|
+
euismod, nisl eget ultricies ultrices, nunc nisi aliquam nisi, eu
|
|
368
|
+
tincidunt nisl nisl eu nisl. Sed euismod, nisl eget ultricies
|
|
369
|
+
ultrices, nunc nisi aliquam nisi, eu tincidunt nisl nisl eu nisl.
|
|
370
|
+
Sed euismod, nisl eget ultricies ultrices, nunc nisi aliquam nisi,
|
|
371
|
+
eu tincidunt nisl nisl eu nisl.
|
|
372
|
+
</p>
|
|
373
|
+
<p>
|
|
374
|
+
Sed euismod, nisl eget ultricies ultrices, nunc nisi aliquam nisi,
|
|
375
|
+
eu tincidunt nisl nisl eu nisl. Sed euismod, nisl eget ultricies
|
|
376
|
+
ultrices, nunc nisi aliquam nisi, eu tincidunt nisl nisl eu nisl.
|
|
377
|
+
Sed euismod, nisl eget ultricies ultrices, nunc nisi aliquam nisi,
|
|
378
|
+
eu tincidunt nisl nisl eu nisl.
|
|
379
|
+
</p>
|
|
380
|
+
<p>
|
|
381
|
+
Sed euismod, nisl eget ultricies ultrices, nunc nisi aliquam nisi,
|
|
382
|
+
eu tincidunt nisl nisl eu nisl. Sed euismod, nisl eget ultricies
|
|
383
|
+
ultrices, nunc nisi aliquam nisi, eu tincidunt nisl nisl eu nisl.
|
|
384
|
+
Sed euismod, nisl eget ultricies ultrices, nunc nisi aliquam nisi,
|
|
385
|
+
eu tincidunt nisl nisl eu nisl.
|
|
386
|
+
</p>
|
|
387
|
+
<p>
|
|
388
|
+
Sed euismod, nisl eget ultricies ultrices, nunc nisi aliquam nisi,
|
|
389
|
+
eu tincidunt nisl nisl eu nisl. Sed euismod, nisl eget ultricies
|
|
390
|
+
ultrices, nunc nisi aliquam nisi, eu tincidunt nisl nisl eu nisl.
|
|
391
|
+
Sed euismod, nisl eget ultricies ultrices, nunc nisi aliquam nisi,
|
|
392
|
+
eu tincidunt nisl nisl eu nisl.
|
|
393
|
+
</p>
|
|
394
|
+
<p>
|
|
395
|
+
Sed euismod, nisl eget ultricies ultrices, nunc nisi aliquam nisi,
|
|
396
|
+
eu tincidunt nisl nisl eu nisl. Sed euismod, nisl eget ultricies
|
|
397
|
+
ultrices, nunc nisi aliquam nisi, eu tincidunt nisl nisl eu nisl.
|
|
398
|
+
Sed euismod, nisl eget ultricies ultrices, nunc nisi aliquam nisi,
|
|
399
|
+
eu tincidunt nisl nisl eu nisl.
|
|
400
|
+
</p>
|
|
401
|
+
</div>
|
|
402
|
+
</Panel>
|
|
403
|
+
</StyledPanelGroup>
|
|
404
|
+
);
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
export function Collapsible(props: {
|
|
408
|
+
handle?: Ref<PanelGroupHandle>;
|
|
409
|
+
rightPanelHandle?: Ref<PanelHandle>;
|
|
410
|
+
leftPanelHandle?: Ref<PanelHandle>;
|
|
411
|
+
}) {
|
|
412
|
+
const [collapsed, setCollapsed] = createSignal(true);
|
|
413
|
+
|
|
414
|
+
return (
|
|
415
|
+
<StyledPanelGroup handle={props.handle}>
|
|
416
|
+
<StyledPanel
|
|
417
|
+
handle={props.leftPanelHandle}
|
|
418
|
+
min="100px"
|
|
419
|
+
collapsible
|
|
420
|
+
collapsedSize="60px"
|
|
421
|
+
style={{ border: "10px solid green", "box-sizing": "border-box" }}
|
|
422
|
+
onCollapseChange={(isCollapsed) => {
|
|
423
|
+
console.log("COLLAPSE PASSIVE", isCollapsed);
|
|
424
|
+
}}
|
|
425
|
+
>
|
|
426
|
+
<div>1</div>
|
|
427
|
+
</StyledPanel>
|
|
428
|
+
<StyledResizer />
|
|
429
|
+
<StyledPanel min="100px">
|
|
430
|
+
<div>2</div>
|
|
431
|
+
</StyledPanel>
|
|
432
|
+
<StyledResizer id="resizer-2" />
|
|
433
|
+
<StyledPanel
|
|
434
|
+
handle={props.rightPanelHandle}
|
|
435
|
+
min="100px"
|
|
436
|
+
collapsible
|
|
437
|
+
collapsedSize="60px"
|
|
438
|
+
collapseAnimation={{ easing: "bounce", duration: 1000 }}
|
|
439
|
+
style={{ border: "10px solid blue", "box-sizing": "border-box" }}
|
|
440
|
+
collapsed={collapsed}
|
|
441
|
+
onCollapseChange={setCollapsed}
|
|
442
|
+
>
|
|
443
|
+
<div>3</div>
|
|
444
|
+
</StyledPanel>
|
|
445
|
+
</StyledPanelGroup>
|
|
446
|
+
);
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
export function CustomCollapseAnimation() {
|
|
450
|
+
const springFn = spring({
|
|
451
|
+
keyframes: [0, 1],
|
|
452
|
+
velocity: 1,
|
|
453
|
+
stiffness: 100,
|
|
454
|
+
damping: 10,
|
|
455
|
+
mass: 1.0,
|
|
456
|
+
});
|
|
457
|
+
|
|
458
|
+
return (
|
|
459
|
+
<StyledPanelGroup>
|
|
460
|
+
<StyledPanel
|
|
461
|
+
min="100px"
|
|
462
|
+
collapsible
|
|
463
|
+
collapsedSize="60px"
|
|
464
|
+
style={{ border: "10px solid green", "box-sizing": "border-box" }}
|
|
465
|
+
>
|
|
466
|
+
1
|
|
467
|
+
</StyledPanel>
|
|
468
|
+
<StyledResizer />
|
|
469
|
+
<StyledPanel min="100px">2</StyledPanel>
|
|
470
|
+
<StyledResizer />
|
|
471
|
+
<StyledPanel
|
|
472
|
+
style={{ border: "10px solid blue", "box-sizing": "border-box" }}
|
|
473
|
+
min="100px"
|
|
474
|
+
collapsible
|
|
475
|
+
collapsedSize="60px"
|
|
476
|
+
defaultCollapsed
|
|
477
|
+
collapseAnimation={{
|
|
478
|
+
easing: (t) => springFn.next(t * 1000).value,
|
|
479
|
+
duration: 1000,
|
|
480
|
+
}}
|
|
481
|
+
>
|
|
482
|
+
3
|
|
483
|
+
</StyledPanel>
|
|
484
|
+
</StyledPanelGroup>
|
|
485
|
+
);
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
export function ImperativePanel() {
|
|
489
|
+
let groupRef: PanelGroupHandle | undefined;
|
|
490
|
+
let panelRef: PanelHandle | undefined;
|
|
491
|
+
|
|
492
|
+
return (
|
|
493
|
+
<>
|
|
494
|
+
<StyledPanelGroup handle={(v) => (groupRef = v)}>
|
|
495
|
+
<StyledPanel
|
|
496
|
+
handle={(v) => (panelRef = v)}
|
|
497
|
+
min="100px"
|
|
498
|
+
collapsible
|
|
499
|
+
collapsedSize="60px"
|
|
500
|
+
>
|
|
501
|
+
1
|
|
502
|
+
</StyledPanel>
|
|
503
|
+
<StyledResizer />
|
|
504
|
+
<StyledPanel min="100px">2</StyledPanel>
|
|
505
|
+
<StyledResizer />
|
|
506
|
+
<StyledPanel
|
|
507
|
+
min="100px"
|
|
508
|
+
collapsible
|
|
509
|
+
collapsedSize="60px"
|
|
510
|
+
defaultCollapsed
|
|
511
|
+
>
|
|
512
|
+
3
|
|
513
|
+
</StyledPanel>
|
|
514
|
+
</StyledPanelGroup>
|
|
515
|
+
|
|
516
|
+
<div>
|
|
517
|
+
<button
|
|
518
|
+
type="button"
|
|
519
|
+
onClick={() => alert(`Sizes: ${groupRef?.getPixelSizes()}`)}
|
|
520
|
+
>
|
|
521
|
+
Get pixel sizes
|
|
522
|
+
</button>
|
|
523
|
+
<button
|
|
524
|
+
type="button"
|
|
525
|
+
onClick={() => alert(`Sizes: ${groupRef?.getPercentageSizes()}`)}
|
|
526
|
+
>
|
|
527
|
+
Get percent sizes
|
|
528
|
+
</button>
|
|
529
|
+
<button
|
|
530
|
+
type="button"
|
|
531
|
+
onClick={() =>
|
|
532
|
+
groupRef?.setSizes(["200px", "10px", "50%", "10px", "150px"])
|
|
533
|
+
}
|
|
534
|
+
>
|
|
535
|
+
Override sizes
|
|
536
|
+
</button>
|
|
537
|
+
</div>
|
|
538
|
+
|
|
539
|
+
<div>
|
|
540
|
+
<button type="button" onClick={() => panelRef?.collapse()}>
|
|
541
|
+
Collapse
|
|
542
|
+
</button>
|
|
543
|
+
<button
|
|
544
|
+
type="button"
|
|
545
|
+
onClick={() => alert(`Collapsed: ${panelRef?.isCollapsed()}`)}
|
|
546
|
+
>
|
|
547
|
+
Is Collapsed?
|
|
548
|
+
</button>
|
|
549
|
+
<button type="button" onClick={() => panelRef?.expand()}>
|
|
550
|
+
Expand
|
|
551
|
+
</button>
|
|
552
|
+
<button
|
|
553
|
+
type="button"
|
|
554
|
+
onClick={() => alert(`Expanded: ${panelRef?.isExpanded()}`)}
|
|
555
|
+
>
|
|
556
|
+
Is Expanded?
|
|
557
|
+
</button>
|
|
558
|
+
<button type="button" onClick={() => alert(`Id: ${panelRef?.getId()}`)}>
|
|
559
|
+
Get Id
|
|
560
|
+
</button>
|
|
561
|
+
<button
|
|
562
|
+
type="button"
|
|
563
|
+
onClick={() => alert(`Size: ${panelRef?.getPixelSize()}`)}
|
|
564
|
+
>
|
|
565
|
+
Get Pixel Size
|
|
566
|
+
</button>
|
|
567
|
+
<button
|
|
568
|
+
type="button"
|
|
569
|
+
onClick={() => alert(`Percentage: ${panelRef?.getPercentageSize()}`)}
|
|
570
|
+
>
|
|
571
|
+
Get Percentage Size
|
|
572
|
+
</button>
|
|
573
|
+
<button type="button" onClick={() => panelRef?.setSize("30px")}>
|
|
574
|
+
Set size to 100px
|
|
575
|
+
</button>
|
|
576
|
+
<button type="button" onClick={() => panelRef?.setSize("50%")}>
|
|
577
|
+
Set size to 50%
|
|
578
|
+
</button>
|
|
579
|
+
</div>
|
|
580
|
+
</>
|
|
581
|
+
);
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
export function ConditionalPanel(props: { handle?: Ref<PanelGroupHandle> }) {
|
|
585
|
+
const [isExpanded, setIsExpanded] = createSignal(false);
|
|
586
|
+
|
|
587
|
+
return (
|
|
588
|
+
<>
|
|
589
|
+
<StyledPanelGroup handle={props.handle}>
|
|
590
|
+
<StyledPanel id="panel-1" min="100px" collapsible collapsedSize="60px">
|
|
591
|
+
<div>1</div>
|
|
592
|
+
</StyledPanel>
|
|
593
|
+
<StyledResizer id="handle-1" />
|
|
594
|
+
<StyledPanel id="panel-2" min="100px">
|
|
595
|
+
<div>2</div>
|
|
596
|
+
</StyledPanel>
|
|
597
|
+
|
|
598
|
+
{isExpanded() && (
|
|
599
|
+
<>
|
|
600
|
+
<StyledResizer id="handle-2" />
|
|
601
|
+
<StyledPanel id="panel-3" min="100px">
|
|
602
|
+
3
|
|
603
|
+
<button type="button" onClick={() => setIsExpanded(false)}>
|
|
604
|
+
Close
|
|
605
|
+
</button>
|
|
606
|
+
</StyledPanel>
|
|
607
|
+
</>
|
|
608
|
+
)}
|
|
609
|
+
</StyledPanelGroup>
|
|
610
|
+
|
|
611
|
+
<button type="button" onClick={() => setIsExpanded(true)}>
|
|
612
|
+
Expand
|
|
613
|
+
</button>
|
|
614
|
+
</>
|
|
615
|
+
);
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
export function ConditionalPanelComplex() {
|
|
619
|
+
const [isExpanded, setIsExpanded] = createSignal(false);
|
|
620
|
+
|
|
621
|
+
return (
|
|
622
|
+
<>
|
|
623
|
+
<StyledPanelGroup>
|
|
624
|
+
<StyledPanel id="panel-1" min="100px" collapsible collapsedSize="60px">
|
|
625
|
+
<div>1</div>
|
|
626
|
+
</StyledPanel>
|
|
627
|
+
<StyledResizer id="handle-1" />
|
|
628
|
+
<StyledPanel id="panel-2" min="100px">
|
|
629
|
+
<div>2</div>
|
|
630
|
+
</StyledPanel>
|
|
631
|
+
<StyledResizer id="handle-2" />
|
|
632
|
+
<StyledPanel id="panel-3" min="100px">
|
|
633
|
+
<div>3</div>
|
|
634
|
+
</StyledPanel>
|
|
635
|
+
<Show when={isExpanded()}>
|
|
636
|
+
<StyledResizer id="handle-3" />
|
|
637
|
+
<StyledPanel id="panel-4" min="100px">
|
|
638
|
+
expanded
|
|
639
|
+
<button type="button" onClick={() => setIsExpanded(false)}>
|
|
640
|
+
Close
|
|
641
|
+
</button>
|
|
642
|
+
</StyledPanel>
|
|
643
|
+
</Show>
|
|
644
|
+
<StyledResizer id="handle-4" />
|
|
645
|
+
<StyledPanel
|
|
646
|
+
min="200px"
|
|
647
|
+
collapsible
|
|
648
|
+
collapsedSize="60px"
|
|
649
|
+
defaultCollapsed
|
|
650
|
+
id="panel-5"
|
|
651
|
+
>
|
|
652
|
+
<div>4</div>
|
|
653
|
+
</StyledPanel>
|
|
654
|
+
</StyledPanelGroup>
|
|
655
|
+
<button type="button" onClick={() => setIsExpanded(true)}>
|
|
656
|
+
Expand
|
|
657
|
+
</button>
|
|
658
|
+
</>
|
|
659
|
+
);
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
export function WithDefaultWidth() {
|
|
663
|
+
return (
|
|
664
|
+
<PanelGroup style={{ height: "400px" }}>
|
|
665
|
+
<Panel style={{ "background-color": "#333366" }} />
|
|
666
|
+
<PanelResizer size="3px" />
|
|
667
|
+
<Panel
|
|
668
|
+
default="100px"
|
|
669
|
+
min="100px"
|
|
670
|
+
max="400px"
|
|
671
|
+
style={{ "background-color": "#ff3366" }}
|
|
672
|
+
/>
|
|
673
|
+
</PanelGroup>
|
|
674
|
+
);
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
export function StaticAtRest() {
|
|
678
|
+
return (
|
|
679
|
+
<StyledPanelGroup style={{ height: "200px" }}>
|
|
680
|
+
<StyledPanel min="100px" max="300px" isStaticAtRest>
|
|
681
|
+
Panel 1
|
|
682
|
+
</StyledPanel>
|
|
683
|
+
<StyledResizer />
|
|
684
|
+
<StyledPanel min="100px">Panel 2</StyledPanel>
|
|
685
|
+
<StyledResizer />
|
|
686
|
+
<StyledPanel min="100px">Panel 3</StyledPanel>
|
|
687
|
+
</StyledPanelGroup>
|
|
688
|
+
);
|
|
689
|
+
}
|