UNPKG

2.48 kBTypeScriptView Raw
1/*
2 * Copyright 2020 Ladifire. All rights reserved.
3 * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License. You may obtain a copy
5 * of the License at http://www.apache.org/licenses/LICENSE-2.0
6 *
7 * Unless required by applicable law or agreed to in writing, software distributed under
8 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9 * OF ANY KIND, either express or implied. See the License for the specific language
10 * governing permissions and limitations under the License.
11 */
12
13import {
14 Dispatch,
15 MouseEventHandler,
16 MutableRefObject,
17 ReactElement,
18 SetStateAction
19} from 'react';
20import {Orientation} from './orientation';
21
22export interface SplitViewStatelyProps {
23 allowsCollapsing?: boolean,
24 onResize?: (primarySize: number) => void,
25 onResizeEnd?: (primarySize: number) => void,
26 primarySize?: number,
27 defaultPrimarySize?: number
28}
29
30export interface SplitViewHandleState {
31 offset: number,
32 dragging: boolean,
33 hovered: boolean,
34 setOffset: (value: number) => void,
35 setDragging: (value: boolean) => void,
36 setHover: (value: boolean) => void,
37 increment: () => void,
38 decrement: () => void,
39 incrementToMax: () => void,
40 decrementToMin: () => void,
41 collapseToggle: () => void
42}
43
44export interface SplitViewContainerState {
45 minPos: number,
46 maxPos: number,
47 setMinPos: Dispatch<SetStateAction<number>>,
48 setMaxPos: Dispatch<SetStateAction<number>>
49}
50
51export interface SplitViewState {
52 handleState: SplitViewHandleState,
53 containerState: SplitViewContainerState
54}
55
56export interface SplitViewAriaProps {
57 id?: string,
58 onMouseDown?: MouseEventHandler,
59 allowsResizing?: boolean,
60 orientation?: Orientation,
61 primaryPane?: 0 | 1,
62 primaryMinSize?: number,
63 primaryMaxSize?: number,
64 secondaryMinSize?: number,
65 secondaryMaxSize?: number,
66 'aria-label'?: string,
67 'aria-labelledby'?: string,
68 containerRef?: MutableRefObject<HTMLDivElement>
69}
70
71export interface SplitViewProps {
72 children: [ReactElement, ReactElement],
73 orientation?: Orientation,
74 allowsResizing?: boolean,
75 allowsCollapsing?: boolean,
76 onResize?: (primarySize: number) => void,
77 onResizeEnd?: (primarySize: number) => void,
78 primaryPane?: 0 | 1,
79 primarySize?: number,
80 defaultPrimarySize?: number,
81 primaryMinSize?: number,
82 primaryMaxSize?: number,
83 secondaryMinSize?: number,
84 secondaryMaxSize?: number
85}