-
- {childrenList[0]}
-
+
+ {renderPane(paneConfigs[0], paneStyles[0], primaryIndex === 0)}
+ {childList.length === 2 ? (
-
{childrenList[1]}
-
-
+ ) : null}
+ {renderPane(paneConfigs[1], paneStyles[1], primaryIndex === 1)}
+
);
};
diff --git a/packages/react/src/split/style/index.scss b/packages/react/src/split/style/index.scss
old mode 100755
new mode 100644
index 3144595f6..dcabed665
--- a/packages/react/src/split/style/index.scss
+++ b/packages/react/src/split/style/index.scss
@@ -4,95 +4,168 @@
box-sizing: border-box;
display: flex;
flex: 1;
- height: 100%;
- outline: none;
+ min-width: 0;
+ min-height: 0;
overflow: hidden;
user-select: text;
&_horizontal {
- flex-direction: column;
+ flex-direction: row;
}
&_vertical {
- flex-direction: row;
+ flex-direction: column;
+ width: 100%;
}
}
.#{$prefix}-split-pane {
box-sizing: border-box;
position: relative;
- outline: none;
+ min-width: 0;
+ min-height: 0;
+ overflow: auto;
}
.#{$prefix}-split-bar {
- position: relative;
+ position: absolute;
box-sizing: border-box;
- background-color: var(--ty-split-bar-bg);
- border: 1px solid var(--ty-split-bar-border);
display: flex;
- justify-content: center;
align-items: center;
+ justify-content: center;
+ color: inherit;
+ outline: none;
+ touch-action: none;
+ z-index: 1;
- &::before,
- &::after {
- content: '';
- box-sizing: border-box;
- display: block;
- border: 1px solid var(--ty-split-bar-line);
+ &__slot {
+ position: relative;
+ flex: 0 0 auto;
+ }
+
+ &__slot_horizontal {
+ width: var(--ty-split-bar-size, 2px);
+ }
+
+ &__slot_vertical {
+ height: var(--ty-split-bar-size, 2px);
+ }
+
+ &_horizontal {
+ top: 0;
+ bottom: 0;
+ left: 50%;
+ transform: translateX(-50%);
+ width: var(--ty-split-bar-hit-area-size, 16px);
+ cursor: col-resize;
}
&_vertical {
+ top: 50%;
+ left: 0;
+ right: 0;
+ transform: translateY(-50%);
+ height: var(--ty-split-bar-hit-area-size, 16px);
+ cursor: row-resize;
+ }
+
+ &_disabled {
+ cursor: default;
+ }
+
+ &__visual {
+ position: relative;
+ width: 100%;
height: 100%;
- cursor: col-resize;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ pointer-events: none;
+ }
+
+ &__track {
+ position: absolute;
+ display: block;
+ background-color: var(--ty-split-bar-line, #c8ced5);
+ transition: background-color 0.2s ease;
+ }
+
+ &__handle {
+ position: relative;
+ z-index: 1;
+ box-sizing: border-box;
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ gap: var(--ty-split-bar-grip-gap, 2px);
+ padding: var(--ty-split-bar-handle-padding, 4px);
+ border: 1px solid var(--ty-split-bar-border, #d7dbe0);
+ border-radius: var(--ty-split-bar-handle-radius, 8px);
+ background-color: var(--ty-split-bar-bg, #fafbfc);
+ box-shadow: var(--ty-split-bar-shadow, 0 1px 2px rgb(15 23 42 / 8%));
+ transition:
+ background-color 0.2s ease,
+ border-color 0.2s ease,
+ box-shadow 0.2s ease,
+ transform 0.2s ease;
+ }
+
+ &__grip-dot {
+ width: var(--ty-split-bar-grip-size, 2px);
+ height: var(--ty-split-bar-grip-size, 2px);
+ border-radius: 50%;
+ background-color: var(--ty-split-bar-line, #c8ced5);
+ transition: background-color 0.2s ease;
+ }
+
+ &_horizontal &__track {
+ top: 0;
+ bottom: 0;
+ left: 50%;
+ width: var(--ty-split-bar-size, 2px);
+ transform: translateX(-50%);
+ }
+
+ &_horizontal &__handle {
flex-direction: column;
- border-top: none;
- border-bottom: none;
+ width: var(--ty-split-bar-handle-thickness, 14px);
+ min-height: var(--ty-split-bar-handle-length, 30px);
+ }
- &:active {
- cursor: ew-resize;
- }
+ &_vertical &__track {
+ left: 0;
+ right: 0;
+ top: 50%;
+ height: var(--ty-split-bar-size, 2px);
+ transform: translateY(-50%);
+ }
- &::before,
- &::after {
- height: var(--ty-split-bar-handle-size);
- width: 100%;
- border-left: 0;
- border-right: 0;
- }
+ &_vertical &__handle {
+ flex-direction: row;
+ min-width: var(--ty-split-bar-handle-length, 30px);
+ height: var(--ty-split-bar-handle-thickness, 14px);
+ }
- &::before {
- margin-bottom: var(--ty-split-bar-handle-gap);
- }
+ &:hover:not(.#{$prefix}-split-bar_disabled) &__track,
+ &_dragging &__track {
+ background-color: var(--ty-split-bar-line-active, var(--ty-split-bar-line, #aeb6bf));
+ }
- &::after {
- margin-top: var(--ty-split-bar-handle-gap);
- }
+ &:hover:not(.#{$prefix}-split-bar_disabled) &__handle,
+ &_dragging &__handle {
+ background-color: var(--ty-split-bar-bg-active, #fff);
+ border-color: var(--ty-split-bar-border-active, #c8cdd3);
}
- &_horizontal {
- width: 100%;
- cursor: row-resize;
- border-left: none;
- border-right: none;
-
- &:active {
- cursor: ns-resize;
- }
-
- &::before,
- &::after {
- height: 100%;
- width: var(--ty-split-bar-handle-size);
- border-top: 0;
- border-bottom: 0;
- }
-
- &::before {
- margin-right: var(--ty-split-bar-handle-gap);
- }
-
- &::after {
- margin-left: var(--ty-split-bar-handle-gap);
- }
+ &_dragging &__handle {
+ transform: scale(1.02);
+ }
+
+ &:focus-visible &__handle {
+ box-shadow: var(--ty-split-bar-focus-ring, 0 0 0 3px rgb(110 65 191 / 20%));
+ }
+
+ &_collapsed &__handle {
+ transform: scale(0.96);
}
}
diff --git a/packages/react/src/split/types.ts b/packages/react/src/split/types.ts
index e5484a584..5c09bfb8d 100644
--- a/packages/react/src/split/types.ts
+++ b/packages/react/src/split/types.ts
@@ -1,37 +1,95 @@
import React from 'react';
import { BaseProps, DirectionType } from '../_utils/props';
-import { ResizerProps } from './resizer';
+
+export type SplitOrientation = DirectionType;
+export type SplitPrimary = 'first' | 'second';
+export type SplitSize = number | `${number}px` | `${number}%`;
+
+export type SplitSeparatorRenderProps = {
+ orientation: SplitOrientation;
+ disabled: boolean;
+ dragging: boolean;
+ collapsed: boolean;
+ collapsible: boolean;
+ size: number;
+ hitAreaSize: number;
+ toggleCollapse: () => void;
+};
+
+export interface SplitPaneProps
+ extends BaseProps,
+ Omit