assui 3.2.66 → 3.2.68

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 (44) hide show
  1. package/es/button-drawer/index.d.ts +13 -5
  2. package/es/button-drawer/index.js +20 -20
  3. package/es/button-modal/index.d.ts +13 -5
  4. package/es/button-modal/index.js +19 -20
  5. package/es/index.d.ts +2 -0
  6. package/es/index.js +2 -1
  7. package/es/multi-line-ellipsis-text/index.d.ts +1 -1
  8. package/es/rc-split-view/DraggableHandle.d.ts +19 -0
  9. package/es/rc-split-view/DraggableHandle.js +37 -0
  10. package/es/rc-split-view/View.d.ts +13 -0
  11. package/es/rc-split-view/View.js +28 -0
  12. package/es/rc-split-view/demo/index.modules.less +9 -0
  13. package/es/rc-split-view/index.d.ts +65 -0
  14. package/es/rc-split-view/index.js +240 -0
  15. package/es/rc-split-view/style/index.css +76 -0
  16. package/es/rc-split-view/style/index.d.ts +1 -0
  17. package/es/rc-split-view/style/index.js +1 -0
  18. package/es/rc-split-view/style/index.less +92 -0
  19. package/es/rc-split-view/utils.d.ts +16 -0
  20. package/es/rc-split-view/utils.js +47 -0
  21. package/es/style/variables.less +1 -0
  22. package/lib/button-drawer/index.d.ts +13 -5
  23. package/lib/button-drawer/index.js +19 -19
  24. package/lib/button-modal/index.d.ts +13 -5
  25. package/lib/button-modal/index.js +19 -20
  26. package/lib/index.d.ts +2 -0
  27. package/lib/index.js +8 -0
  28. package/lib/multi-line-ellipsis-text/index.d.ts +1 -1
  29. package/lib/rc-split-view/DraggableHandle.d.ts +19 -0
  30. package/lib/rc-split-view/DraggableHandle.js +47 -0
  31. package/lib/rc-split-view/View.d.ts +13 -0
  32. package/lib/rc-split-view/View.js +38 -0
  33. package/lib/rc-split-view/demo/index.modules.less +9 -0
  34. package/lib/rc-split-view/index.d.ts +65 -0
  35. package/lib/rc-split-view/index.js +251 -0
  36. package/lib/rc-split-view/style/index.css +76 -0
  37. package/lib/rc-split-view/style/index.d.ts +1 -0
  38. package/lib/rc-split-view/style/index.js +6 -0
  39. package/lib/rc-split-view/style/index.less +92 -0
  40. package/lib/rc-split-view/utils.d.ts +16 -0
  41. package/lib/rc-split-view/utils.js +62 -0
  42. package/lib/style/variables.less +1 -0
  43. package/package.json +3 -4
  44. package/LICENSE +0 -21
@@ -4,11 +4,19 @@ export type DrawerAction = {
4
4
  close: () => void;
5
5
  open: () => void;
6
6
  };
7
- export interface ButtonDrawerProps extends Omit<DrawerProps, 'children'> {
8
- onClose?: () => void;
7
+ type ControlledProps = {
8
+ open: boolean;
9
+ onOpen?: () => void;
10
+ onClose: () => void;
11
+ };
12
+ type UncontrolledProps = {
9
13
  onOpen?: () => void;
10
- trigger: React.ReactElement;
14
+ onClose?: () => void;
15
+ };
16
+ export interface BaseButtonDrawerProps extends Omit<DrawerProps, 'children'> {
17
+ trigger?: ((fun: () => void) => React.ReactElement) | React.ReactElement;
11
18
  children: ((v: DrawerAction) => React.ReactElement) | React.ReactElement;
12
19
  }
13
- declare const ForwardRefButtonDrawer: React.ForwardRefExoticComponent<ButtonDrawerProps & React.RefAttributes<unknown>>;
14
- export default ForwardRefButtonDrawer;
20
+ export type ButtonDrawerProps = (BaseButtonDrawerProps & ControlledProps) | (BaseButtonDrawerProps & UncontrolledProps);
21
+ declare const ButtonDrawer: (props: ButtonDrawerProps) => JSX.Element;
22
+ export default ButtonDrawer;
@@ -38,15 +38,13 @@ var __read = this && this.__read || function (o, n) {
38
38
  }
39
39
  return ar;
40
40
  };
41
- import React, { useState, useRef, useImperativeHandle } from 'react';
41
+ import React, { useRef } from 'react';
42
42
  import Drawer from "antd/es/drawer";
43
43
  import isFunction from 'lodash/isFunction';
44
44
  import classNames from 'classnames';
45
45
  import CloseOutlined from "a-icons/es/CloseOutlined";
46
- var ButtonDrawer = function ButtonDrawer(props, ref) {
47
- var _a = __read(useState(false), 2),
48
- drawerVisible = _a[0],
49
- setDrawerVisible = _a[1];
46
+ import { useControllableValue } from 'ahooks';
47
+ var ButtonDrawer = function ButtonDrawer(props) {
50
48
  var children = props.children,
51
49
  onOpen = props.onOpen,
52
50
  onClose = props.onClose,
@@ -54,16 +52,17 @@ var ButtonDrawer = function ButtonDrawer(props, ref) {
54
52
  title = props.title,
55
53
  className = props.className,
56
54
  restProps = __rest(props, ["children", "onOpen", "onClose", "trigger", "title", "className"]);
55
+ var _a = __read(useControllableValue(props, {
56
+ valuePropName: 'open'
57
+ }), 2),
58
+ drawerVisible = _a[0],
59
+ setDrawerVisible = _a[1];
57
60
  var closeDrawer = function closeDrawer() {
58
- if (onClose) {
59
- onClose();
60
- }
61
+ onClose === null || onClose === void 0 ? void 0 : onClose();
61
62
  setDrawerVisible(false);
62
63
  };
63
64
  var openDrawer = function openDrawer() {
64
- if (onOpen) {
65
- onOpen();
66
- }
65
+ onOpen === null || onOpen === void 0 ? void 0 : onOpen();
67
66
  setDrawerVisible(true);
68
67
  };
69
68
  var actionRef = useRef({
@@ -74,13 +73,15 @@ var ButtonDrawer = function ButtonDrawer(props, ref) {
74
73
  openDrawer();
75
74
  }
76
75
  });
77
- useImperativeHandle(ref, function () {
78
- return actionRef.current;
79
- });
80
- var buttonNode = trigger && /*#__PURE__*/React.cloneElement(trigger, {
81
- onClick: openDrawer
82
- });
83
- return /*#__PURE__*/React.createElement(React.Fragment, null, buttonNode, /*#__PURE__*/React.createElement(Drawer, __assign({
76
+ var triggerNode;
77
+ if (isFunction(trigger)) {
78
+ triggerNode = trigger(openDrawer);
79
+ } else {
80
+ triggerNode = trigger && /*#__PURE__*/React.cloneElement(trigger, {
81
+ onClick: openDrawer
82
+ });
83
+ }
84
+ return /*#__PURE__*/React.createElement(React.Fragment, null, triggerNode, /*#__PURE__*/React.createElement(Drawer, __assign({
84
85
  maskClosable: false,
85
86
  className: classNames('button-drawer', className),
86
87
  title: title,
@@ -91,5 +92,4 @@ var ButtonDrawer = function ButtonDrawer(props, ref) {
91
92
  drawerAction: actionRef.current
92
93
  })));
93
94
  };
94
- var ForwardRefButtonDrawer = /*#__PURE__*/React.forwardRef(ButtonDrawer);
95
- export default ForwardRefButtonDrawer;
95
+ export default ButtonDrawer;
@@ -4,11 +4,19 @@ export interface ModalAction {
4
4
  open: () => void;
5
5
  close: () => void;
6
6
  }
7
- export interface ButtonModalProps extends Omit<ModalProps, 'children'> {
8
- onClose?: () => void;
7
+ type ControlledProps = {
8
+ open: boolean;
9
+ onOpen?: () => void;
10
+ onClose: () => void;
11
+ };
12
+ type UncontrolledProps = {
9
13
  onOpen?: () => void;
10
- trigger?: React.ReactElement;
14
+ onClose?: () => void;
15
+ };
16
+ export interface BaseButtonModalProps extends Omit<ModalProps, 'children'> {
17
+ trigger?: ((fun: () => void) => React.ReactElement) | React.ReactElement;
11
18
  children: ((v: ModalAction) => React.ReactElement) | React.ReactElement;
12
19
  }
13
- declare const ForwardRefButtonModal: React.ForwardRefExoticComponent<ButtonModalProps & React.RefAttributes<unknown>>;
14
- export default ForwardRefButtonModal;
20
+ export type ButtonModalProps = (BaseButtonModalProps & ControlledProps) | (BaseButtonModalProps & UncontrolledProps);
21
+ declare const ButtonModal: (props: ButtonModalProps) => JSX.Element;
22
+ export default ButtonModal;
@@ -42,10 +42,8 @@ import * as React from 'react';
42
42
  import isFunction from 'lodash/isFunction';
43
43
  import Modal from "antd/es/modal";
44
44
  import CloseOutlined from "a-icons/es/CloseOutlined";
45
- var ButtonModal = function ButtonModal(props, ref) {
46
- var _a = __read(React.useState(false), 2),
47
- visible = _a[0],
48
- setModalVisible = _a[1];
45
+ import { useControllableValue } from 'ahooks';
46
+ var ButtonModal = function ButtonModal(props) {
49
47
  var children = props.children,
50
48
  trigger = props.trigger,
51
49
  onOpen = props.onOpen,
@@ -53,6 +51,11 @@ var ButtonModal = function ButtonModal(props, ref) {
53
51
  onOk = props.onOk,
54
52
  onCancel = props.onCancel,
55
53
  restModalProps = __rest(props, ["children", "trigger", "onOpen", "onClose", "onOk", "onCancel"]);
54
+ var _a = __read(useControllableValue(props, {
55
+ valuePropName: 'open'
56
+ }), 2),
57
+ visible = _a[0],
58
+ setModalVisible = _a[1];
56
59
  var openModal = function openModal() {
57
60
  setModalVisible(true);
58
61
  onOpen === null || onOpen === void 0 ? void 0 : onOpen();
@@ -65,26 +68,23 @@ var ButtonModal = function ButtonModal(props, ref) {
65
68
  open: openModal,
66
69
  close: closeModal
67
70
  });
68
- React.useImperativeHandle(ref, function () {
69
- return modalActionRef.current;
70
- });
71
71
  var handleModalOk = function handleModalOk(e) {
72
- if (onOk) {
73
- return onOk(e);
74
- }
72
+ onOk === null || onOk === void 0 ? void 0 : onOk(e);
75
73
  closeModal();
76
- return null;
77
74
  };
78
75
  var handleModalCancel = function handleModalCancel(e) {
79
- if (onCancel) {
80
- onCancel(e);
81
- }
76
+ onCancel === null || onCancel === void 0 ? void 0 : onCancel(e);
82
77
  closeModal();
83
78
  };
84
- var buttonNode = trigger && /*#__PURE__*/React.cloneElement(trigger, {
85
- onClick: openModal
86
- });
87
- return /*#__PURE__*/React.createElement(React.Fragment, null, buttonNode, /*#__PURE__*/React.createElement(Modal, __assign({
79
+ var triggerNode;
80
+ if (isFunction(trigger)) {
81
+ triggerNode = trigger(openModal);
82
+ } else {
83
+ triggerNode = trigger && /*#__PURE__*/React.cloneElement(trigger, {
84
+ onClick: openModal
85
+ });
86
+ }
87
+ return /*#__PURE__*/React.createElement(React.Fragment, null, triggerNode, /*#__PURE__*/React.createElement(Modal, __assign({
88
88
  open: visible,
89
89
  onOk: handleModalOk,
90
90
  onCancel: handleModalCancel,
@@ -95,5 +95,4 @@ var ButtonModal = function ButtonModal(props, ref) {
95
95
  modalAction: modalActionRef.current
96
96
  })));
97
97
  };
98
- var ForwardRefButtonModal = /*#__PURE__*/React.forwardRef(ButtonModal);
99
- export default ForwardRefButtonModal;
98
+ export default ButtonModal;
package/es/index.d.ts CHANGED
@@ -94,3 +94,5 @@ export { default as SignaturePad } from './signature-pad';
94
94
  export type { SignaturePadProps } from './signature-pad';
95
95
  export { default as MultiLineEllipsisText } from './multi-line-ellipsis-text';
96
96
  export type { MultiLineEllipsisTextProps } from './multi-line-ellipsis-text';
97
+ export type { RcSplitViewProps } from './rc-split-view';
98
+ export { default as RcSplitView } from './rc-split-view';
package/es/index.js CHANGED
@@ -47,4 +47,5 @@ export { default as CountDown } from './count-down';
47
47
  export { default as CountUp } from './count-up';
48
48
  export { default as ConditionSelect } from './condition-select';
49
49
  export { default as SignaturePad } from './signature-pad';
50
- export { default as MultiLineEllipsisText } from './multi-line-ellipsis-text';
50
+ export { default as MultiLineEllipsisText } from './multi-line-ellipsis-text';
51
+ export { default as RcSplitView } from './rc-split-view';
@@ -19,7 +19,7 @@ export interface MultiLineEllipsisTextProps {
19
19
  /** 省略的回调 */
20
20
  onEllipsisChange?: (isEllipsis: boolean) => void;
21
21
  /** 点击的回调 */
22
- onClick?: () => void;
22
+ onClick?: (e: React.MouseEvent) => void;
23
23
  }
24
24
  declare const MultiLineEllipsisText: React.FC<MultiLineEllipsisTextProps>;
25
25
  export default MultiLineEllipsisText;
@@ -0,0 +1,19 @@
1
+ import React from 'react';
2
+ interface DraggableHandleProps {
3
+ /** 组件样式 */
4
+ className: string;
5
+ /** 点击回调 */
6
+ onClick?: (value: React.MouseEvent<HTMLSpanElement, MouseEvent>) => void;
7
+ /** 双击回调 */
8
+ onDoubleClick?: (value: React.MouseEvent<HTMLSpanElement, MouseEvent>) => void;
9
+ /** 按下鼠标按钮回调 */
10
+ onMouseDown: (value: React.MouseEvent<HTMLSpanElement, MouseEvent>) => void;
11
+ /** 事件在一个或多个触点与触控设备表面接触时被触发 */
12
+ onTouchStart: (value: React.TouchEvent<HTMLSpanElement>) => void;
13
+ /** 事件在一个或多个触点从触控平面上移开时触发 */
14
+ onTouchEnd: (value: React.TouchEvent<HTMLSpanElement>) => void;
15
+ /** 子元素 */
16
+ children?: React.ReactNode;
17
+ }
18
+ declare const DraggableHandle: React.FC<DraggableHandleProps>;
19
+ export default DraggableHandle;
@@ -0,0 +1,37 @@
1
+ import React from 'react';
2
+ var DraggableHandle = function DraggableHandle(props) {
3
+ var className = props.className,
4
+ _onClick = props.onClick,
5
+ _onDoubleClick = props.onDoubleClick,
6
+ _onMouseDown = props.onMouseDown,
7
+ _onTouchEnd = props.onTouchEnd,
8
+ _onTouchStart = props.onTouchStart,
9
+ children = props.children;
10
+ return /*#__PURE__*/React.createElement("div", {
11
+ className: className,
12
+ onMouseDown: function onMouseDown(event) {
13
+ return _onMouseDown(event);
14
+ },
15
+ onTouchStart: function onTouchStart(event) {
16
+ event.preventDefault();
17
+ _onTouchStart(event);
18
+ },
19
+ onTouchEnd: function onTouchEnd(event) {
20
+ event.preventDefault();
21
+ _onTouchEnd(event);
22
+ },
23
+ onClick: function onClick(event) {
24
+ if (_onClick) {
25
+ event.preventDefault();
26
+ _onClick(event);
27
+ }
28
+ },
29
+ onDoubleClick: function onDoubleClick(event) {
30
+ if (_onDoubleClick) {
31
+ event.preventDefault();
32
+ _onDoubleClick(event);
33
+ }
34
+ }
35
+ }, children);
36
+ };
37
+ export default DraggableHandle;
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ interface ViewProps {
3
+ /** 子元素 */
4
+ children: React.ReactNode;
5
+ /** 样式 */
6
+ className?: string;
7
+ /** 拆分方式 */
8
+ split: 'vertical' | 'horizontal';
9
+ /** 大小 */
10
+ size?: string | number;
11
+ }
12
+ declare const View: React.ForwardRefExoticComponent<ViewProps & React.RefAttributes<HTMLDivElement>>;
13
+ export default View;
@@ -0,0 +1,28 @@
1
+ import React from 'react';
2
+ import isUndefined from 'lodash/isUndefined';
3
+ var View = /*#__PURE__*/React.forwardRef(function (props, ref) {
4
+ var children = props.children,
5
+ className = props.className,
6
+ split = props.split,
7
+ size = props.size;
8
+ var viewStyle = {
9
+ flex: 1,
10
+ position: 'relative',
11
+ outline: 'none'
12
+ };
13
+ if (!isUndefined(size)) {
14
+ if (split === 'vertical') {
15
+ viewStyle.width = size;
16
+ } else {
17
+ viewStyle.height = size;
18
+ viewStyle.display = 'flex';
19
+ }
20
+ viewStyle.flex = 'none';
21
+ }
22
+ return /*#__PURE__*/React.createElement("div", {
23
+ ref: ref,
24
+ className: className,
25
+ style: viewStyle
26
+ }, children);
27
+ });
28
+ export default View;
@@ -0,0 +1,9 @@
1
+ .handle {
2
+ position: absolute;
3
+ top: 50%;
4
+ left: 5px;
5
+ width: 4px;
6
+ height: 40px;
7
+ background-color: red;
8
+ transform: translateY(-50%);
9
+ }
@@ -0,0 +1,65 @@
1
+ import React from 'react';
2
+ import View from './View';
3
+ export { View };
4
+ export interface RcSplitViewProps {
5
+ /** 是否允许拖动 */
6
+ draggable?: boolean;
7
+ /** children */
8
+ children: React.ReactNode;
9
+ /** 自定义组件类名 */
10
+ className?: string;
11
+ /** 拖拽条单击回调 */
12
+ onResizerClick?: (event: React.MouseEvent<HTMLSpanElement, MouseEvent>) => void;
13
+ /** 拖拽条双击回调 */
14
+ onResizerDoubleClick?: (event: React.MouseEvent<HTMLSpanElement, MouseEvent>) => void;
15
+ /** 面板样式 */
16
+ viewClassName?: string;
17
+ /** 第一个面板样式 */
18
+ firstViewClassName?: string;
19
+ /** 第二个面板样式 */
20
+ secondViewClassName?: string;
21
+ /** 分隔条样式 */
22
+ handleClassName?: string;
23
+ /** 分隔条内容样式 */
24
+ handleContentClassName?: string;
25
+ /** 拆分方式 */
26
+ split?: 'vertical' | 'horizontal';
27
+ /** 拖拽过程回调 */
28
+ onChange?: (newSize: number) => void;
29
+ /** 拖拽开始回调 */
30
+ onDragStarted?: () => void;
31
+ /** 拖拽完成回调 */
32
+ onDragFinished?: (newSize: number) => void;
33
+ /** 主体窗口 */
34
+ primary?: 'first' | 'second';
35
+ /** 拖动固定步进值 */
36
+ step?: number;
37
+ /** 最大窗口大小 */
38
+ maxSize?: number;
39
+ /** 最小窗口大小 */
40
+ minSize?: number;
41
+ /** 窗口大小 */
42
+ size?: string | number;
43
+ /** 默认窗口大小 */
44
+ defaultSize?: string | number;
45
+ /** 分隔条内容 */
46
+ handleContent?: React.ReactNode;
47
+ }
48
+ export type StatesTypes = {
49
+ /** 激活 */
50
+ active: boolean;
51
+ /** 位置 */
52
+ position: number;
53
+ /** 拖拽尺寸 */
54
+ draggedSize?: number;
55
+ /** 实例参数 */
56
+ instanceProps: {
57
+ size?: string | number;
58
+ };
59
+ /** 第一面板的尺寸 */
60
+ firstViewSize?: number | string;
61
+ /** 第二面板的尺寸 */
62
+ secondViewSize?: number | string;
63
+ };
64
+ declare const RcSplitView: React.FC<RcSplitViewProps>;
65
+ export default RcSplitView;
@@ -0,0 +1,240 @@
1
+ var __assign = this && this.__assign || function () {
2
+ __assign = Object.assign || function (t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
6
+ }
7
+ return t;
8
+ };
9
+ return __assign.apply(this, arguments);
10
+ };
11
+ var __read = this && this.__read || function (o, n) {
12
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
13
+ if (!m) return o;
14
+ var i = m.call(o),
15
+ r,
16
+ ar = [],
17
+ e;
18
+ try {
19
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
20
+ } catch (error) {
21
+ e = {
22
+ error: error
23
+ };
24
+ } finally {
25
+ try {
26
+ if (r && !r.done && (m = i["return"])) m.call(i);
27
+ } finally {
28
+ if (e) throw e.error;
29
+ }
30
+ }
31
+ return ar;
32
+ };
33
+ import React from 'react';
34
+ import useGetState from "ahooks/es/useGetState";
35
+ import useMount from "ahooks/es/useMount";
36
+ import useUnmount from "ahooks/es/useUnmount";
37
+ import classNames from 'classnames';
38
+ import isUndefined from 'lodash/isUndefined';
39
+ import View from './View';
40
+ import DraggableHandle from './DraggableHandle';
41
+ import { getSizeUpdate, removeNullChildren, getDefaultSize, unFocus } from './utils';
42
+ export { View };
43
+ var RcSplitView = function RcSplitView(props) {
44
+ var _a;
45
+ var _b = props.draggable,
46
+ draggable = _b === void 0 ? true : _b,
47
+ children = props.children,
48
+ className = props.className,
49
+ onResizerClick = props.onResizerClick,
50
+ onResizerDoubleClick = props.onResizerDoubleClick,
51
+ viewClassName = props.viewClassName,
52
+ firstViewClassName = props.firstViewClassName,
53
+ secondViewClassName = props.secondViewClassName,
54
+ handleClassName = props.handleClassName,
55
+ _c = props.split,
56
+ split = _c === void 0 ? 'vertical' : _c,
57
+ onDragStarted = props.onDragStarted,
58
+ onDragFinished = props.onDragFinished,
59
+ _d = props.primary,
60
+ primary = _d === void 0 ? 'first' : _d,
61
+ step = props.step,
62
+ maxSize = props.maxSize,
63
+ _e = props.minSize,
64
+ minSize = _e === void 0 ? 50 : _e,
65
+ onChange = props.onChange,
66
+ size = props.size,
67
+ defaultSize = props.defaultSize,
68
+ handleContent = props.handleContent,
69
+ handleContentClassName = props.handleContentClassName;
70
+ var initialSize = isUndefined(size) ? getDefaultSize(defaultSize, minSize, maxSize) : size;
71
+ var initialValue = {
72
+ active: false,
73
+ firstViewSize: primary === 'first' ? initialSize : undefined,
74
+ secondViewSize: primary === 'second' ? initialSize : undefined,
75
+ // these are props that are needed in static functions. ie: gDSFP
76
+ instanceProps: {
77
+ size: size
78
+ },
79
+ position: 0
80
+ };
81
+ var splitViewRef = React.useRef(null);
82
+ var firstViewRef = React.useRef(null);
83
+ var secondViewRef = React.useRef(null);
84
+ var _f = __read(useGetState(initialValue), 3),
85
+ states = _f[0],
86
+ setStates = _f[1],
87
+ getStates = _f[2];
88
+ var onTouchStart = function onTouchStart(event) {
89
+ var currentValue = getStates();
90
+ if (draggable) {
91
+ unFocus(document, window);
92
+ var _a = event.touches[0],
93
+ clientX = _a.clientX,
94
+ clientY = _a.clientY;
95
+ var position = split === 'vertical' ? clientX : clientY;
96
+ onDragStarted === null || onDragStarted === void 0 ? void 0 : onDragStarted();
97
+ setStates(__assign(__assign({}, currentValue), {
98
+ active: true,
99
+ position: position
100
+ }));
101
+ }
102
+ };
103
+ var onMouseDown = function onMouseDown(event) {
104
+ var eventWithTouches = __assign(__assign({}, event), {
105
+ touches: [{
106
+ clientX: event.clientX,
107
+ clientY: event.clientY
108
+ }]
109
+ });
110
+ onTouchStart(eventWithTouches);
111
+ };
112
+ var onMouseUp = function onMouseUp() {
113
+ var currentValue = getStates();
114
+ var active = currentValue.active,
115
+ draggedSize = currentValue.draggedSize;
116
+ if (draggable && active && draggedSize) {
117
+ onDragFinished === null || onDragFinished === void 0 ? void 0 : onDragFinished(draggedSize);
118
+ setStates(__assign(__assign({}, currentValue), {
119
+ active: false
120
+ }));
121
+ }
122
+ };
123
+ var onTouchMove = function onTouchMove(event) {
124
+ var _a;
125
+ var _b;
126
+ var currentValue = getStates();
127
+ var active = currentValue.active,
128
+ position = currentValue.position;
129
+ if (draggable && active) {
130
+ unFocus(document, window);
131
+ var isFirstPrimary = primary === 'first';
132
+ var firstRef = isFirstPrimary ? firstViewRef.current : secondViewRef.current;
133
+ var secondRef = isFirstPrimary ? secondViewRef.current : firstViewRef.current;
134
+ if (firstRef && secondRef) {
135
+ var firstNode = firstRef;
136
+ var secondNode = secondRef;
137
+ if (firstNode.getBoundingClientRect) {
138
+ var _c = firstNode.getBoundingClientRect(),
139
+ width = _c.width,
140
+ height = _c.height;
141
+ var current = split === 'vertical' ? event.touches[0].clientX : event.touches[0].clientY;
142
+ var nodeSize = split === 'vertical' ? width : height;
143
+ var positionDelta = position - current;
144
+ if (step) {
145
+ if (Math.abs(positionDelta) < step) {
146
+ return;
147
+ }
148
+ positionDelta = Math.trunc(positionDelta / step) * step;
149
+ }
150
+ var sizeDelta = isFirstPrimary ? positionDelta : -positionDelta;
151
+ var firstViewOrder = parseInt(window.getComputedStyle(firstNode).order, 10);
152
+ var secondViewOrder = parseInt(window.getComputedStyle(secondNode).order, 10);
153
+ if (firstViewOrder > secondViewOrder) {
154
+ sizeDelta = -sizeDelta;
155
+ }
156
+ var newMaxSize = maxSize || 0;
157
+ if (!isUndefined(maxSize) && maxSize <= 0) {
158
+ if (split === 'vertical') {
159
+ newMaxSize = ((_b = splitViewRef.current.getBoundingClientRect()) === null || _b === void 0 ? void 0 : _b.width) + maxSize;
160
+ } else {
161
+ newMaxSize = splitViewRef.current.getBoundingClientRect().height + maxSize;
162
+ }
163
+ }
164
+ var newSize = +nodeSize - sizeDelta;
165
+ var newPosition = position - positionDelta;
166
+ var restValue = {};
167
+ if (newSize < minSize) {
168
+ newSize = minSize;
169
+ } else if (!isUndefined(maxSize) && newSize > newMaxSize) {
170
+ newSize = newMaxSize;
171
+ } else {
172
+ restValue = {
173
+ position: newPosition
174
+ };
175
+ }
176
+ onChange === null || onChange === void 0 ? void 0 : onChange(newSize);
177
+ setStates(__assign(__assign(__assign({}, currentValue), (_a = {
178
+ draggedSize: newSize
179
+ }, _a[isFirstPrimary ? 'firstViewSize' : 'secondViewSize'] = newSize, _a)), restValue));
180
+ }
181
+ }
182
+ }
183
+ };
184
+ var onMouseMove = function onMouseMove(event) {
185
+ var eventWithTouches = __assign(__assign({}, event), {
186
+ touches: [{
187
+ clientX: event.clientX,
188
+ clientY: event.clientY
189
+ }]
190
+ });
191
+ onTouchMove(eventWithTouches);
192
+ };
193
+ useMount(function () {
194
+ document.addEventListener('mouseup', onMouseUp);
195
+ document.addEventListener('mousemove', onMouseMove);
196
+ document.addEventListener('touchmove', onTouchMove);
197
+ setStates(getSizeUpdate({
198
+ size: size,
199
+ defaultSize: defaultSize,
200
+ maxSize: maxSize,
201
+ minSize: minSize,
202
+ primary: primary
203
+ }, states));
204
+ });
205
+ useUnmount(function () {
206
+ document.removeEventListener('mouseup', onMouseUp);
207
+ document.removeEventListener('mousemove', onMouseMove);
208
+ document.removeEventListener('touchmove', onTouchMove);
209
+ });
210
+ var _g = __read(removeNullChildren(children), 2),
211
+ firstViewNode = _g[0],
212
+ secondViewNode = _g[1];
213
+ return /*#__PURE__*/React.createElement("div", {
214
+ className: classNames('split-view', "split-view-".concat(split), className),
215
+ ref: splitViewRef
216
+ }, /*#__PURE__*/React.createElement(View, {
217
+ className: classNames(viewClassName, firstViewClassName),
218
+ key: "first-view",
219
+ ref: firstViewRef,
220
+ size: states.firstViewSize,
221
+ split: split
222
+ }, firstViewNode), /*#__PURE__*/React.createElement(DraggableHandle, {
223
+ className: classNames('split-view-draggable-handle', (_a = {}, _a["split-view-draggable-handle-".concat(split, "-disabled")] = !draggable, _a), "split-view-draggable-handle-".concat(split), handleClassName),
224
+ onClick: onResizerClick,
225
+ onDoubleClick: onResizerDoubleClick,
226
+ onMouseDown: onMouseDown,
227
+ onTouchStart: onTouchStart,
228
+ onTouchEnd: onMouseUp,
229
+ key: "draggableHandle"
230
+ }, draggable && /*#__PURE__*/React.createElement("div", {
231
+ className: classNames("split-view-draggable-handle-".concat(split, "-content"), handleContentClassName)
232
+ }, handleContent)), /*#__PURE__*/React.createElement(View, {
233
+ className: classNames(viewClassName, secondViewClassName),
234
+ key: "second-view",
235
+ ref: secondViewRef,
236
+ size: states.secondViewSize,
237
+ split: split
238
+ }, secondViewNode));
239
+ };
240
+ export default RcSplitView;