yootd 0.0.60 → 0.0.61
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.
@@ -4,6 +4,7 @@
|
|
4
4
|
padding: 12px 16px;
|
5
5
|
box-sizing: border-box;
|
6
6
|
cursor: pointer;
|
7
|
+
background-color: #fff;
|
7
8
|
&-top {
|
8
9
|
display: flex;
|
9
10
|
justify-content: space-between;
|
@@ -77,6 +78,7 @@
|
|
77
78
|
right: 16px;
|
78
79
|
height: 1px;
|
79
80
|
background-color: #e5e5e5;
|
81
|
+
z-index: 100;
|
80
82
|
}
|
81
83
|
&__content-active {
|
82
84
|
background-color: #d1eaff;
|
@@ -89,5 +91,6 @@
|
|
89
91
|
width: 4px;
|
90
92
|
height: 100%;
|
91
93
|
background-color: #4d8de2;
|
94
|
+
|
92
95
|
}
|
93
96
|
}
|
package/dist/aside/index.js
CHANGED
@@ -12,7 +12,7 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
|
|
12
12
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
13
13
|
import { DndContext, KeyboardSensor, PointerSensor, closestCenter, useSensor, useSensors } from '@dnd-kit/core';
|
14
14
|
import { SortableContext, arrayMove, sortableKeyboardCoordinates, verticalListSortingStrategy } from '@dnd-kit/sortable';
|
15
|
-
import React, { useEffect, useState } from 'react';
|
15
|
+
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
16
16
|
import { useBem } from "../hooks/useBem";
|
17
17
|
import { AddBtnIcon } from "./components/AddBtnIcon";
|
18
18
|
import SortableItem from "./components/SortableItem";
|
@@ -26,6 +26,8 @@ export var Aside = function Aside(_ref) {
|
|
26
26
|
activeKey = _ref.activeKey,
|
27
27
|
title = _ref.title,
|
28
28
|
data = _ref.data,
|
29
|
+
_ref$overflow = _ref.overflow,
|
30
|
+
overflow = _ref$overflow === void 0 ? false : _ref$overflow,
|
29
31
|
_ref$titleShow = _ref.titleShow,
|
30
32
|
titleShow = _ref$titleShow === void 0 ? true : _ref$titleShow,
|
31
33
|
_ref$addBtnIcon = _ref.addBtnIcon,
|
@@ -43,8 +45,12 @@ export var Aside = function Aside(_ref) {
|
|
43
45
|
onEdit = _ref.onEdit,
|
44
46
|
onDel = _ref.onDel,
|
45
47
|
onSwitch = _ref.onSwitch,
|
46
|
-
onDragEnd = _ref.onDragEnd
|
48
|
+
onDragEnd = _ref.onDragEnd,
|
49
|
+
onScrollBottom = _ref.onScrollBottom,
|
50
|
+
_ref$bottomThreshold = _ref.bottomThreshold,
|
51
|
+
bottomThreshold = _ref$bottomThreshold === void 0 ? 50 : _ref$bottomThreshold;
|
47
52
|
var mb = useBem('aside');
|
53
|
+
var asideRef = useRef(null);
|
48
54
|
// 当前选择的key
|
49
55
|
var _useState = useState(),
|
50
56
|
_useState2 = _slicedToArray(_useState, 2),
|
@@ -121,6 +127,28 @@ export var Aside = function Aside(_ref) {
|
|
121
127
|
}
|
122
128
|
};
|
123
129
|
|
130
|
+
// 添加滚动处理函数
|
131
|
+
var handleScroll = useCallback(function () {
|
132
|
+
if (!asideRef.current || !onScrollBottom) return;
|
133
|
+
var _asideRef$current = asideRef.current,
|
134
|
+
scrollTop = _asideRef$current.scrollTop,
|
135
|
+
scrollHeight = _asideRef$current.scrollHeight,
|
136
|
+
clientHeight = _asideRef$current.clientHeight;
|
137
|
+
if (scrollTop + clientHeight + bottomThreshold >= scrollHeight) {
|
138
|
+
onScrollBottom();
|
139
|
+
}
|
140
|
+
}, [onScrollBottom, bottomThreshold]);
|
141
|
+
|
142
|
+
// 添加滚动监听
|
143
|
+
useEffect(function () {
|
144
|
+
var asideElement = asideRef.current;
|
145
|
+
if (!asideElement || !overflow) return;
|
146
|
+
asideElement.addEventListener('scroll', handleScroll);
|
147
|
+
return function () {
|
148
|
+
asideElement.removeEventListener('scroll', handleScroll);
|
149
|
+
};
|
150
|
+
}, [handleScroll, overflow]);
|
151
|
+
|
124
152
|
// 给key设置初始值
|
125
153
|
useEffect(function () {
|
126
154
|
if (activeKey) {
|
@@ -137,10 +165,13 @@ export var Aside = function Aside(_ref) {
|
|
137
165
|
}
|
138
166
|
}, [data]);
|
139
167
|
return /*#__PURE__*/React.createElement("div", {
|
168
|
+
ref: asideRef,
|
140
169
|
className: "".concat(mb),
|
141
170
|
style: _objectSpread(_objectSpread({}, style), {}, {
|
142
171
|
width: width,
|
143
|
-
height: height
|
172
|
+
height: height,
|
173
|
+
overflowX: overflow ? 'hidden' : 'visible',
|
174
|
+
overflowY: overflow ? 'auto' : 'visible'
|
144
175
|
})
|
145
176
|
}, titleShow && /*#__PURE__*/React.createElement("div", {
|
146
177
|
className: "".concat(mb.b('title'))
|
package/dist/aside/index.scss
CHANGED
@@ -4,12 +4,15 @@
|
|
4
4
|
box-sizing: border-box;
|
5
5
|
&-title {
|
6
6
|
border-bottom: 1px solid #e5e5e5;
|
7
|
-
padding: 16px
|
8
|
-
margin: 0px 16px;
|
7
|
+
padding: 16px 16px;
|
9
8
|
box-sizing: border-box;
|
10
9
|
display: flex;
|
11
10
|
align-items: start;
|
12
11
|
justify-content: space-between;
|
12
|
+
background-color: #fff;
|
13
|
+
position: sticky;
|
14
|
+
top: 0;
|
15
|
+
z-index: 999;
|
13
16
|
&__title-text {
|
14
17
|
font-size: 18px;
|
15
18
|
font-weight: bold;
|
@@ -23,3 +26,21 @@
|
|
23
26
|
}
|
24
27
|
}
|
25
28
|
}
|
29
|
+
// 滚动条宽度
|
30
|
+
.yot-aside::-webkit-scrollbar {
|
31
|
+
width: 6px;
|
32
|
+
height: 10px;
|
33
|
+
}
|
34
|
+
// 滚动条轨道
|
35
|
+
.yot-aside::-webkit-scrollbar-track {
|
36
|
+
background: white;
|
37
|
+
border-radius: 2px;
|
38
|
+
height: 10px;
|
39
|
+
}
|
40
|
+
// 小滑块
|
41
|
+
.yot-aside::-webkit-scrollbar-thumb {
|
42
|
+
background: rgba(0, 0, 0, 0.15);
|
43
|
+
border-radius: 10px;
|
44
|
+
height: 10px;
|
45
|
+
}
|
46
|
+
|
@@ -1,44 +1,47 @@
|
|
1
|
-
type IdataItem = {
|
2
|
-
key: string;
|
3
|
-
title: string;
|
4
|
-
extra?: string;
|
5
|
-
checked?: boolean;
|
6
|
-
};
|
7
|
-
export type AsideProps = {
|
8
|
-
width?: number;
|
9
|
-
height?: number | string;
|
10
|
-
style?: React.CSSProperties;
|
11
|
-
activeKey?: string;
|
12
|
-
title?: string;
|
13
|
-
data: IdataItem[];
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
1
|
+
type IdataItem = {
|
2
|
+
key: string;
|
3
|
+
title: string;
|
4
|
+
extra?: string;
|
5
|
+
checked?: boolean;
|
6
|
+
};
|
7
|
+
export type AsideProps = {
|
8
|
+
width?: number;
|
9
|
+
height?: number | string;
|
10
|
+
style?: React.CSSProperties;
|
11
|
+
activeKey?: string;
|
12
|
+
title?: string;
|
13
|
+
data: IdataItem[];
|
14
|
+
overflow?: boolean;
|
15
|
+
titleShow?: boolean;
|
16
|
+
addBtnIcon?: boolean;
|
17
|
+
editBtnIcon?: boolean;
|
18
|
+
delBtnIcon?: boolean;
|
19
|
+
switchBtnIcon?: boolean;
|
20
|
+
dragBtnIcon?: boolean;
|
21
|
+
onClick?: (key: string, e: IdataItem) => void;
|
22
|
+
onAdd?: () => void;
|
23
|
+
onEdit?: (key: string, e: IdataItem) => void;
|
24
|
+
onDel?: (key: string, e: IdataItem) => void;
|
25
|
+
onSwitch?: (
|
26
|
+
changeValue: { key: string; checked: boolean },
|
27
|
+
data: IdataItem[],
|
28
|
+
) => void;
|
29
|
+
onDragEnd?: (data: IdataItem[]) => void;
|
30
|
+
onScrollBottom?: () => void;
|
31
|
+
bottomThreshold?: number;
|
32
|
+
};
|
33
|
+
export type AsideItemProps = {
|
34
|
+
activeKey: string;
|
35
|
+
id: string;
|
36
|
+
title: string;
|
37
|
+
editBtnIcon?: boolean;
|
38
|
+
delBtnIcon?: boolean;
|
39
|
+
switchBtnIcon?: boolean;
|
40
|
+
dragBtnIcon?: boolean;
|
41
|
+
checked?: boolean;
|
42
|
+
extra?: string;
|
43
|
+
onClick?: (key: string, e: IdataItem) => void;
|
44
|
+
onEdit?: (key: string, e: IdataItem) => void;
|
45
|
+
onDel?: (key: string, e: IdataItem) => void;
|
46
|
+
onSwitch?: (key: string, e: boolean) => void;
|
47
|
+
};
|