@arco-design/mobile-react 2.26.0 → 2.27.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/CHANGELOG.md +18 -0
- package/README.en-US.md +2 -2
- package/README.md +2 -2
- package/cjs/form/form-item.js +4 -2
- package/cjs/icon/IconHeart/index.js +1 -1
- package/cjs/icon/IconKeyboard/index.d.ts +7 -0
- package/cjs/icon/IconKeyboard/index.js +48 -0
- package/cjs/icon/IconKeyboardDelete/index.d.ts +7 -0
- package/cjs/icon/IconKeyboardDelete/index.js +44 -0
- package/cjs/icon/IconMinus/index.js +1 -1
- package/cjs/icon/IconMore/index.js +1 -1
- package/cjs/icon/IconNotice/index.js +1 -1
- package/cjs/icon/IconNoticeOff/index.js +1 -1
- package/cjs/icon/IconPlay/index.js +1 -1
- package/cjs/icon/IconSetting/index.js +2 -2
- package/cjs/icon/IconSound/index.js +1 -1
- package/cjs/icon/IconStar/index.js +1 -1
- package/cjs/icon/IconStarFill/index.js +1 -1
- package/cjs/icon/IconTriDown/index.js +1 -1
- package/cjs/icon/IconTriUp/index.js +1 -1
- package/cjs/icon/IconUpload/index.js +1 -1
- package/cjs/icon/IconWarnCircle/index.js +1 -1
- package/cjs/icon/IconWarnCircleFill/index.js +1 -1
- package/cjs/icon/index.d.ts +2 -0
- package/cjs/icon/index.js +12 -2
- package/cjs/image-picker/style/css/index.d.ts +1 -0
- package/cjs/image-picker/style/css/index.js +2 -0
- package/cjs/image-picker/style/index.d.ts +1 -0
- package/cjs/image-picker/style/index.js +2 -0
- package/cjs/index-bar/context.d.ts +3 -0
- package/cjs/index-bar/context.js +15 -0
- package/cjs/index-bar/demo/style/css/mobile.css +23 -0
- package/cjs/index-bar/demo/style/mobile.less +26 -0
- package/cjs/index-bar/group.d.ts +3 -0
- package/cjs/index-bar/group.js +101 -0
- package/cjs/index-bar/index.d.ts +15 -0
- package/cjs/index-bar/index.js +276 -0
- package/cjs/index-bar/side-bar.d.ts +3 -0
- package/cjs/index-bar/side-bar.js +102 -0
- package/cjs/index-bar/style/css/index.css +164 -0
- package/cjs/index-bar/style/css/index.d.ts +3 -0
- package/cjs/index-bar/style/css/index.js +7 -0
- package/cjs/index-bar/style/index.d.ts +3 -0
- package/cjs/index-bar/style/index.js +7 -0
- package/cjs/index-bar/style/index.less +122 -0
- package/cjs/index-bar/type.d.ts +195 -0
- package/cjs/index-bar/type.js +3 -0
- package/cjs/index-bar/utils.d.ts +6 -0
- package/cjs/index-bar/utils.js +68 -0
- package/cjs/index.d.ts +2 -0
- package/cjs/index.js +9 -1
- package/cjs/keyboard/demo/style/css/mobile.css +4 -0
- package/cjs/keyboard/demo/style/mobile.less +8 -0
- package/cjs/keyboard/index.d.ts +13 -0
- package/cjs/keyboard/index.js +270 -0
- package/cjs/keyboard/style/css/index.css +93 -0
- package/cjs/keyboard/style/css/index.d.ts +3 -0
- package/cjs/keyboard/style/css/index.js +7 -0
- package/cjs/keyboard/style/index.d.ts +3 -0
- package/cjs/keyboard/style/index.js +7 -0
- package/cjs/keyboard/style/index.less +80 -0
- package/cjs/keyboard/type.d.ts +102 -0
- package/cjs/keyboard/type.js +3 -0
- package/cjs/picker/index.js +3 -39
- package/cjs/picker/type.d.ts +1 -1
- package/cjs/picker-view/components/cascader.d.ts +2 -3
- package/cjs/picker-view/components/cascader.js +8 -6
- package/cjs/picker-view/components/multi-picker.d.ts +2 -3
- package/cjs/picker-view/components/multi-picker.js +31 -35
- package/cjs/picker-view/components/picker-cell.d.ts +1 -1
- package/cjs/picker-view/components/picker-cell.js +5 -7
- package/cjs/picker-view/index.d.ts +1 -1
- package/cjs/picker-view/index.js +9 -20
- package/cjs/picker-view/type.d.ts +2 -2
- package/cjs/slider/hooks/useSliderEvents.js +20 -20
- package/cjs/sticky/index.js +2 -2
- package/cjs/style.d.ts +2 -0
- package/cjs/style.js +4 -0
- package/dist/index.js +1793 -483
- package/dist/index.min.js +4 -4
- package/dist/style.css +215 -1
- package/dist/style.min.css +1 -1
- package/esm/form/form-item.js +4 -2
- package/esm/icon/IconHeart/index.js +1 -1
- package/esm/icon/IconKeyboard/index.d.ts +7 -0
- package/esm/icon/IconKeyboard/index.js +37 -0
- package/esm/icon/IconKeyboardDelete/index.d.ts +7 -0
- package/esm/icon/IconKeyboardDelete/index.js +33 -0
- package/esm/icon/IconMinus/index.js +1 -1
- package/esm/icon/IconMore/index.js +1 -1
- package/esm/icon/IconNotice/index.js +1 -1
- package/esm/icon/IconNoticeOff/index.js +1 -1
- package/esm/icon/IconPlay/index.js +1 -1
- package/esm/icon/IconSetting/index.js +2 -2
- package/esm/icon/IconSound/index.js +1 -1
- package/esm/icon/IconStar/index.js +1 -1
- package/esm/icon/IconStarFill/index.js +1 -1
- package/esm/icon/IconTriDown/index.js +1 -1
- package/esm/icon/IconTriUp/index.js +1 -1
- package/esm/icon/IconUpload/index.js +1 -1
- package/esm/icon/IconWarnCircle/index.js +1 -1
- package/esm/icon/IconWarnCircleFill/index.js +1 -1
- package/esm/icon/index.d.ts +2 -0
- package/esm/icon/index.js +2 -0
- package/esm/image-picker/style/css/index.d.ts +1 -0
- package/esm/image-picker/style/css/index.js +1 -0
- package/esm/image-picker/style/index.d.ts +1 -0
- package/esm/image-picker/style/index.js +1 -0
- package/esm/index-bar/context.d.ts +3 -0
- package/esm/index-bar/context.js +8 -0
- package/esm/index-bar/demo/style/css/mobile.css +23 -0
- package/esm/index-bar/demo/style/mobile.less +26 -0
- package/esm/index-bar/group.d.ts +3 -0
- package/esm/index-bar/group.js +83 -0
- package/esm/index-bar/index.d.ts +15 -0
- package/esm/index-bar/index.js +254 -0
- package/esm/index-bar/side-bar.d.ts +3 -0
- package/esm/index-bar/side-bar.js +90 -0
- package/esm/index-bar/style/css/index.css +164 -0
- package/esm/index-bar/style/css/index.d.ts +3 -0
- package/esm/index-bar/style/css/index.js +3 -0
- package/esm/index-bar/style/index.d.ts +3 -0
- package/esm/index-bar/style/index.js +3 -0
- package/esm/index-bar/style/index.less +122 -0
- package/esm/index-bar/type.d.ts +195 -0
- package/esm/index-bar/type.js +1 -0
- package/esm/index-bar/utils.d.ts +6 -0
- package/esm/index-bar/utils.js +53 -0
- package/esm/index.d.ts +2 -0
- package/esm/index.js +2 -0
- package/esm/keyboard/demo/style/css/mobile.css +4 -0
- package/esm/keyboard/demo/style/mobile.less +8 -0
- package/esm/keyboard/index.d.ts +13 -0
- package/esm/keyboard/index.js +243 -0
- package/esm/keyboard/style/css/index.css +93 -0
- package/esm/keyboard/style/css/index.d.ts +3 -0
- package/esm/keyboard/style/css/index.js +3 -0
- package/esm/keyboard/style/index.d.ts +3 -0
- package/esm/keyboard/style/index.js +3 -0
- package/esm/keyboard/style/index.less +80 -0
- package/esm/keyboard/type.d.ts +102 -0
- package/esm/keyboard/type.js +1 -0
- package/esm/picker/index.js +3 -40
- package/esm/picker/type.d.ts +1 -1
- package/esm/picker-view/components/cascader.d.ts +2 -3
- package/esm/picker-view/components/cascader.js +8 -6
- package/esm/picker-view/components/multi-picker.d.ts +2 -3
- package/esm/picker-view/components/multi-picker.js +31 -34
- package/esm/picker-view/components/picker-cell.d.ts +1 -1
- package/esm/picker-view/components/picker-cell.js +5 -7
- package/esm/picker-view/index.d.ts +1 -1
- package/esm/picker-view/index.js +10 -21
- package/esm/picker-view/type.d.ts +2 -2
- package/esm/slider/hooks/useSliderEvents.js +20 -20
- package/esm/sticky/index.js +2 -2
- package/esm/style.d.ts +2 -0
- package/esm/style.js +2 -0
- package/package.json +3 -3
- package/tokens/app/arcodesign/default/css-variables.less +43 -0
- package/tokens/app/arcodesign/default/index.d.ts +43 -0
- package/tokens/app/arcodesign/default/index.js +43 -0
- package/tokens/app/arcodesign/default/index.json +516 -0
- package/tokens/app/arcodesign/default/index.less +43 -0
- package/umd/form/form-item.js +4 -2
- package/umd/icon/IconHeart/index.js +1 -1
- package/umd/icon/IconKeyboard/index.d.ts +7 -0
- package/umd/icon/IconKeyboard/index.js +56 -0
- package/umd/icon/IconKeyboardDelete/index.d.ts +7 -0
- package/umd/icon/IconKeyboardDelete/index.js +52 -0
- package/umd/icon/IconMinus/index.js +1 -1
- package/umd/icon/IconMore/index.js +1 -1
- package/umd/icon/IconNotice/index.js +1 -1
- package/umd/icon/IconNoticeOff/index.js +1 -1
- package/umd/icon/IconPlay/index.js +1 -1
- package/umd/icon/IconSetting/index.js +2 -2
- package/umd/icon/IconSound/index.js +1 -1
- package/umd/icon/IconStar/index.js +1 -1
- package/umd/icon/IconStarFill/index.js +1 -1
- package/umd/icon/IconTriDown/index.js +1 -1
- package/umd/icon/IconTriUp/index.js +1 -1
- package/umd/icon/IconUpload/index.js +1 -1
- package/umd/icon/IconWarnCircle/index.js +1 -1
- package/umd/icon/IconWarnCircleFill/index.js +1 -1
- package/umd/icon/index.d.ts +2 -0
- package/umd/icon/index.js +12 -6
- package/umd/image-picker/style/css/index.d.ts +1 -0
- package/umd/image-picker/style/css/index.js +4 -4
- package/umd/image-picker/style/index.d.ts +1 -0
- package/umd/image-picker/style/index.js +4 -4
- package/umd/index-bar/context.d.ts +3 -0
- package/umd/index-bar/context.js +26 -0
- package/umd/index-bar/demo/style/css/mobile.css +23 -0
- package/umd/index-bar/demo/style/mobile.less +26 -0
- package/umd/index-bar/group.d.ts +3 -0
- package/umd/index-bar/group.js +107 -0
- package/umd/index-bar/index.d.ts +15 -0
- package/umd/index-bar/index.js +274 -0
- package/umd/index-bar/side-bar.d.ts +3 -0
- package/umd/index-bar/side-bar.js +113 -0
- package/umd/index-bar/style/css/index.css +164 -0
- package/umd/index-bar/style/css/index.d.ts +3 -0
- package/umd/index-bar/style/css/index.js +15 -0
- package/umd/index-bar/style/index.d.ts +3 -0
- package/umd/index-bar/style/index.js +15 -0
- package/umd/index-bar/style/index.less +122 -0
- package/umd/index-bar/type.d.ts +195 -0
- package/umd/index-bar/type.js +17 -0
- package/umd/index-bar/utils.d.ts +6 -0
- package/umd/index-bar/utils.js +78 -0
- package/umd/index.d.ts +2 -0
- package/umd/index.js +9 -5
- package/umd/keyboard/demo/style/css/mobile.css +4 -0
- package/umd/keyboard/demo/style/mobile.less +8 -0
- package/umd/keyboard/index.d.ts +13 -0
- package/umd/keyboard/index.js +271 -0
- package/umd/keyboard/style/css/index.css +93 -0
- package/umd/keyboard/style/css/index.d.ts +3 -0
- package/umd/keyboard/style/css/index.js +15 -0
- package/umd/keyboard/style/index.d.ts +3 -0
- package/umd/keyboard/style/index.js +15 -0
- package/umd/keyboard/style/index.less +80 -0
- package/umd/keyboard/type.d.ts +102 -0
- package/umd/keyboard/type.js +17 -0
- package/umd/picker/index.js +3 -39
- package/umd/picker/type.d.ts +1 -1
- package/umd/picker-view/components/cascader.d.ts +2 -3
- package/umd/picker-view/components/cascader.js +8 -6
- package/umd/picker-view/components/multi-picker.d.ts +2 -3
- package/umd/picker-view/components/multi-picker.js +31 -35
- package/umd/picker-view/components/picker-cell.d.ts +1 -1
- package/umd/picker-view/components/picker-cell.js +5 -7
- package/umd/picker-view/index.d.ts +1 -1
- package/umd/picker-view/index.js +9 -20
- package/umd/picker-view/type.d.ts +2 -2
- package/umd/slider/hooks/useSliderEvents.js +20 -20
- package/umd/sticky/index.js +2 -2
- package/umd/style.d.ts +2 -0
- package/umd/style.js +4 -4
@@ -0,0 +1,276 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
+
|
5
|
+
exports.__esModule = true;
|
6
|
+
exports.default = void 0;
|
7
|
+
|
8
|
+
var _mobileUtils = require("@arco-design/mobile-utils");
|
9
|
+
|
10
|
+
var _utils = require("@arco-design/mobile-utils/utils");
|
11
|
+
|
12
|
+
var _lodash = _interopRequireDefault(require("lodash.throttle"));
|
13
|
+
|
14
|
+
var _react = _interopRequireWildcard(require("react"));
|
15
|
+
|
16
|
+
var _contextProvider = require("../context-provider");
|
17
|
+
|
18
|
+
var _context = require("./context");
|
19
|
+
|
20
|
+
var _group = require("./group");
|
21
|
+
|
22
|
+
var _sideBar = require("./side-bar");
|
23
|
+
|
24
|
+
var _utils2 = require("./utils");
|
25
|
+
|
26
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
27
|
+
|
28
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
29
|
+
|
30
|
+
var IndexBar = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
31
|
+
var _props$className = props.className,
|
32
|
+
className = _props$className === void 0 ? '' : _props$className,
|
33
|
+
style = props.style,
|
34
|
+
children = props.children,
|
35
|
+
_props$sticky = props.sticky,
|
36
|
+
sticky = _props$sticky === void 0 ? true : _props$sticky,
|
37
|
+
_props$groups = props.groups,
|
38
|
+
groups = _props$groups === void 0 ? [] : _props$groups,
|
39
|
+
_props$tipType = props.tipType,
|
40
|
+
tipType = _props$tipType === void 0 ? 'toast' : _props$tipType,
|
41
|
+
defaultIndex = props.defaultIndex,
|
42
|
+
scrollBezier = props.scrollBezier,
|
43
|
+
_props$scrollDuration = props.scrollDuration,
|
44
|
+
scrollDuration = _props$scrollDuration === void 0 ? 0 : _props$scrollDuration,
|
45
|
+
_props$disableSidebar = props.disableSidebar,
|
46
|
+
disableSidebar = _props$disableSidebar === void 0 ? false : _props$disableSidebar,
|
47
|
+
onChange = props.onChange,
|
48
|
+
onGroupItemClick = props.onGroupItemClick,
|
49
|
+
renderSideBar = props.renderSideBar,
|
50
|
+
renderSideBarItem = props.renderSideBarItem,
|
51
|
+
renderTip = props.renderTip,
|
52
|
+
renderStickyItem = props.renderStickyItem,
|
53
|
+
renderGroupItem = props.renderGroupItem; // 最外层dom元素的ref
|
54
|
+
|
55
|
+
var domRef = (0, _react.useRef)(null); // 所有group的容器dom,domRef的内容就是contanerRef和sidebar的内容
|
56
|
+
|
57
|
+
var containerRef = (0, _react.useRef)(null); // 过滤掉jsx写法中,奇怪的child
|
58
|
+
|
59
|
+
var formatChildren = (0, _utils2.filterValidIndexBarChild)(children); // 所有的索引内容,优先从props.groups中获取,再从formatChildren中获取
|
60
|
+
|
61
|
+
var indexes = (0, _react.useMemo)(function () {
|
62
|
+
if (groups.length) {
|
63
|
+
return groups.map(function (group) {
|
64
|
+
return group.index;
|
65
|
+
});
|
66
|
+
}
|
67
|
+
|
68
|
+
return formatChildren.map(function (child) {
|
69
|
+
return child.props.index;
|
70
|
+
});
|
71
|
+
}, [children, groups]);
|
72
|
+
var groupRefs = (0, _react.useRef)({}); // 当前激活的Index
|
73
|
+
|
74
|
+
var _useState = (0, _react.useState)(function () {
|
75
|
+
return defaultIndex != null ? defaultIndex : indexes == null ? void 0 : indexes[0];
|
76
|
+
}),
|
77
|
+
activeIndex = _useState[0],
|
78
|
+
setActiveIndex = _useState[1]; // 给IndexBarGroup用的上下文,主要是为了兼容jsx的写法
|
79
|
+
|
80
|
+
|
81
|
+
var contextValue = (0, _react.useMemo)(function () {
|
82
|
+
return {
|
83
|
+
sticky: sticky,
|
84
|
+
getScrollContainer: function getScrollContainer() {
|
85
|
+
return containerRef.current;
|
86
|
+
},
|
87
|
+
activeIndex: activeIndex,
|
88
|
+
updateRef: function updateRef(groupIndex, stickyRef) {
|
89
|
+
groupRefs.current[groupIndex] = stickyRef;
|
90
|
+
}
|
91
|
+
};
|
92
|
+
}, [sticky, activeIndex]); // 用户是否正在触碰sidebar, 如果为true的话,禁用handleScroll的处理
|
93
|
+
|
94
|
+
var isScrollHandlerDisabledRef = (0, _react.useRef)(false);
|
95
|
+
|
96
|
+
var handleChangeActiveIndex = function handleChangeActiveIndex(index, type) {
|
97
|
+
setActiveIndex(function (oldActiveIndex) {
|
98
|
+
var newActiveIndex = (0, _utils2.getFormatIndex)(index, oldActiveIndex); // 和上一次激活的acitveIndex不同,再触发onChange事件
|
99
|
+
|
100
|
+
if (newActiveIndex !== oldActiveIndex) {
|
101
|
+
onChange == null ? void 0 : onChange(newActiveIndex, type);
|
102
|
+
}
|
103
|
+
|
104
|
+
return newActiveIndex;
|
105
|
+
});
|
106
|
+
}; // 要滚动到哪个指定的index
|
107
|
+
|
108
|
+
|
109
|
+
var handleScrollIntoIndex = function handleScrollIntoIndex(params) {
|
110
|
+
var index = params.index,
|
111
|
+
type = params.type,
|
112
|
+
_params$rightNow = params.rightNow,
|
113
|
+
rightNow = _params$rightNow === void 0 ? false : _params$rightNow; // 不传index默认走第一个index
|
114
|
+
|
115
|
+
var formatIndex = index != null ? index : indexes == null ? void 0 : indexes[0];
|
116
|
+
var containerDom = containerRef.current;
|
117
|
+
|
118
|
+
if (!(0, _utils2.isValidIndex)(index) || !containerDom) {
|
119
|
+
return;
|
120
|
+
} // 寻找Index对应的groupDom
|
121
|
+
|
122
|
+
|
123
|
+
var groupDom = (0, _utils2.getGroupDomFromIndex)(containerDom, formatIndex);
|
124
|
+
|
125
|
+
if (groupDom) {
|
126
|
+
handleChangeActiveIndex(formatIndex, type);
|
127
|
+
var duration = rightNow ? 0 : scrollDuration;
|
128
|
+
var targetScrollTop = groupDom.offsetTop; // 将屏幕滚动到groupDom
|
129
|
+
// 手动触发需要禁用handleScroll事件
|
130
|
+
|
131
|
+
if (type === 'manual') {
|
132
|
+
isScrollHandlerDisabledRef.current = true;
|
133
|
+
setTimeout(function () {
|
134
|
+
isScrollHandlerDisabledRef.current = false;
|
135
|
+
}, duration);
|
136
|
+
}
|
137
|
+
|
138
|
+
if (duration > 0) {
|
139
|
+
(0, _utils.scrollWithAnimation)(containerDom.scrollTop, targetScrollTop, function (top) {
|
140
|
+
return containerDom.scrollTop = top;
|
141
|
+
}, duration, scrollBezier);
|
142
|
+
} else {
|
143
|
+
containerDom.scrollTop = targetScrollTop;
|
144
|
+
}
|
145
|
+
}
|
146
|
+
};
|
147
|
+
|
148
|
+
(0, _react.useImperativeHandle)(ref, function () {
|
149
|
+
return {
|
150
|
+
dom: domRef.current,
|
151
|
+
scrollToIndex: function scrollToIndex(index, rightNow) {
|
152
|
+
if ((0, _utils2.isValidIndex)(index)) {
|
153
|
+
handleScrollIntoIndex({
|
154
|
+
index: index,
|
155
|
+
rightNow: rightNow,
|
156
|
+
type: 'manual'
|
157
|
+
});
|
158
|
+
}
|
159
|
+
},
|
160
|
+
recalculatePosition: function recalculatePosition(targetIndex) {
|
161
|
+
var formatIndex = targetIndex != null ? targetIndex : activeIndex;
|
162
|
+
|
163
|
+
if (formatIndex) {
|
164
|
+
var targetStickyRef = groupRefs.current[formatIndex];
|
165
|
+
|
166
|
+
if (targetStickyRef && targetStickyRef.recalculatePosition) {
|
167
|
+
targetStickyRef.recalculatePosition();
|
168
|
+
}
|
169
|
+
}
|
170
|
+
}
|
171
|
+
};
|
172
|
+
});
|
173
|
+
|
174
|
+
var renderChildren = function renderChildren() {
|
175
|
+
if (formatChildren.length) {
|
176
|
+
return formatChildren;
|
177
|
+
}
|
178
|
+
|
179
|
+
return groups == null ? void 0 : groups.map(function (group) {
|
180
|
+
return /*#__PURE__*/_react.default.createElement(_group.IndexBarGroup, {
|
181
|
+
index: group.index,
|
182
|
+
key: group.index,
|
183
|
+
list: group.list,
|
184
|
+
onGroupItemClick: onGroupItemClick,
|
185
|
+
renderGroupItem: renderGroupItem,
|
186
|
+
renderStickyItem: renderStickyItem
|
187
|
+
});
|
188
|
+
});
|
189
|
+
};
|
190
|
+
|
191
|
+
(0, _react.useEffect)(function () {
|
192
|
+
var _containerRef$current;
|
193
|
+
|
194
|
+
var handleScroll = (0, _lodash.default)(function () {
|
195
|
+
// 用户正在触碰sidebar和手动触发scroll时禁用滚动事件的处理
|
196
|
+
if (!containerRef.current || isScrollHandlerDisabledRef.current) {
|
197
|
+
return;
|
198
|
+
} // 根据滚动的距离,获取处于屏幕最顶部的group是哪个
|
199
|
+
|
200
|
+
|
201
|
+
var scrollTop = containerRef.current.scrollTop;
|
202
|
+
|
203
|
+
for (var i = 0; i < containerRef.current.children.length; i++) {
|
204
|
+
var child = containerRef.current.children[i];
|
205
|
+
|
206
|
+
if (!child || !child.dataset || typeof child.dataset.index === 'undefined') {
|
207
|
+
continue;
|
208
|
+
}
|
209
|
+
|
210
|
+
if (child.offsetTop + child.clientHeight >= scrollTop) {
|
211
|
+
handleChangeActiveIndex(child.dataset.index, 'swipe');
|
212
|
+
break;
|
213
|
+
}
|
214
|
+
}
|
215
|
+
}, 100); // 页面挂载时,如果是传入了defaultIndex,则滚动到对应位置
|
216
|
+
|
217
|
+
if (activeIndex) {
|
218
|
+
handleScrollIntoIndex({
|
219
|
+
index: activeIndex,
|
220
|
+
rightNow: true,
|
221
|
+
type: 'manual'
|
222
|
+
});
|
223
|
+
}
|
224
|
+
|
225
|
+
(_containerRef$current = containerRef.current) == null ? void 0 : _containerRef$current.addEventListener('scroll', handleScroll);
|
226
|
+
return function () {
|
227
|
+
var _containerRef$current2;
|
228
|
+
|
229
|
+
(_containerRef$current2 = containerRef.current) == null ? void 0 : _containerRef$current2.removeEventListener('scroll', handleScroll);
|
230
|
+
};
|
231
|
+
}, []);
|
232
|
+
return /*#__PURE__*/_react.default.createElement(_contextProvider.ContextLayout, null, function (_ref) {
|
233
|
+
var prefixCls = _ref.prefixCls;
|
234
|
+
return /*#__PURE__*/_react.default.createElement(_context.IndexBarContext.Provider, {
|
235
|
+
value: contextValue
|
236
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
237
|
+
className: (0, _mobileUtils.cls)(prefixCls + "-index-bar", className),
|
238
|
+
style: style,
|
239
|
+
ref: domRef
|
240
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
241
|
+
className: prefixCls + "-index-bar-container",
|
242
|
+
ref: containerRef
|
243
|
+
}, renderChildren()), !disableSidebar && /*#__PURE__*/_react.default.createElement(_sideBar.IndexBarSideBar, {
|
244
|
+
tipType: tipType,
|
245
|
+
activeIndex: activeIndex,
|
246
|
+
prefixCls: prefixCls,
|
247
|
+
indexes: indexes,
|
248
|
+
onTouching: function onTouching(isTouching) {
|
249
|
+
return isScrollHandlerDisabledRef.current = isTouching;
|
250
|
+
},
|
251
|
+
onClick: function onClick(newIndex) {
|
252
|
+
return handleScrollIntoIndex({
|
253
|
+
index: newIndex,
|
254
|
+
type: 'sidebar'
|
255
|
+
});
|
256
|
+
},
|
257
|
+
renderSideBar: renderSideBar,
|
258
|
+
renderSideBarItem: renderSideBarItem,
|
259
|
+
renderTip: renderTip
|
260
|
+
})));
|
261
|
+
});
|
262
|
+
});
|
263
|
+
/**
|
264
|
+
* 索引栏组件
|
265
|
+
* @en IndexBar component
|
266
|
+
* @type 导航
|
267
|
+
* @type_en Navigation
|
268
|
+
* @name 索引栏
|
269
|
+
* @name_en SearchBar
|
270
|
+
*/
|
271
|
+
|
272
|
+
var _default = (0, _mobileUtils.componentWrapper)(IndexBar, {
|
273
|
+
Group: _group.IndexBarGroup
|
274
|
+
});
|
275
|
+
|
276
|
+
exports.default = _default;
|
@@ -0,0 +1,102 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
exports.__esModule = true;
|
4
|
+
exports.IndexBarSideBar = IndexBarSideBar;
|
5
|
+
|
6
|
+
var _react = _interopRequireWildcard(require("react"));
|
7
|
+
|
8
|
+
var _mobileUtils = require("@arco-design/mobile-utils");
|
9
|
+
|
10
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
11
|
+
|
12
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
13
|
+
|
14
|
+
function IndexBarSideBar(props) {
|
15
|
+
var _cls;
|
16
|
+
|
17
|
+
var indexes = props.indexes,
|
18
|
+
prefixCls = props.prefixCls,
|
19
|
+
onTouching = props.onTouching,
|
20
|
+
onClick = props.onClick,
|
21
|
+
activeIndex = props.activeIndex,
|
22
|
+
tipType = props.tipType,
|
23
|
+
renderSideBar = props.renderSideBar,
|
24
|
+
_props$renderSideBarI = props.renderSideBarItem,
|
25
|
+
renderSideBarItem = _props$renderSideBarI === void 0 ? function (index) {
|
26
|
+
return index;
|
27
|
+
} : _props$renderSideBarI,
|
28
|
+
propsRenderTip = props.renderTip;
|
29
|
+
|
30
|
+
var _useState = (0, _react.useState)(false),
|
31
|
+
isTouching = _useState[0],
|
32
|
+
originSetIsTouching = _useState[1];
|
33
|
+
|
34
|
+
var setIsTouching = function setIsTouching(touching) {
|
35
|
+
originSetIsTouching(touching);
|
36
|
+
onTouching(touching);
|
37
|
+
};
|
38
|
+
|
39
|
+
var handleTouchingStart = function handleTouchingStart() {
|
40
|
+
return setIsTouching(true);
|
41
|
+
};
|
42
|
+
|
43
|
+
var handleTouchingStop = function handleTouchingStop() {
|
44
|
+
return setIsTouching(false);
|
45
|
+
};
|
46
|
+
|
47
|
+
var handleTouchMove = function handleTouchMove(e) {
|
48
|
+
var _e$touches, _target$dataset;
|
49
|
+
|
50
|
+
if (!isTouching || !((_e$touches = e.touches) != null && _e$touches.length)) {
|
51
|
+
return;
|
52
|
+
}
|
53
|
+
|
54
|
+
var _e$touches$ = e.touches[0],
|
55
|
+
clientX = _e$touches$.clientX,
|
56
|
+
clientY = _e$touches$.clientY;
|
57
|
+
var target = document.elementFromPoint(clientX, clientY);
|
58
|
+
|
59
|
+
if (target && (_target$dataset = target.dataset) != null && _target$dataset.index) {
|
60
|
+
onClick(target.dataset.index);
|
61
|
+
}
|
62
|
+
};
|
63
|
+
|
64
|
+
var renderSideBarTip = function renderSideBarTip(index, type) {
|
65
|
+
if (propsRenderTip) {
|
66
|
+
return propsRenderTip(index);
|
67
|
+
}
|
68
|
+
|
69
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
70
|
+
className: prefixCls + "-index-bar-sidebar-" + type
|
71
|
+
}, index);
|
72
|
+
};
|
73
|
+
|
74
|
+
var node = /*#__PURE__*/_react.default.createElement("div", {
|
75
|
+
className: (0, _mobileUtils.cls)(prefixCls + "-index-bar-sidebar", (_cls = {}, _cls[prefixCls + "-index-bar-sidebar-touching"] = isTouching, _cls)),
|
76
|
+
onTouchStart: function onTouchStart() {
|
77
|
+
return handleTouchingStart();
|
78
|
+
},
|
79
|
+
onTouchEnd: function onTouchEnd() {
|
80
|
+
return handleTouchingStop();
|
81
|
+
},
|
82
|
+
onTouchCancel: function onTouchCancel() {
|
83
|
+
return handleTouchingStop();
|
84
|
+
},
|
85
|
+
onTouchMove: handleTouchMove
|
86
|
+
}, tipType === 'toast' && isTouching && activeIndex && renderSideBarTip(activeIndex, 'toast'), indexes.map(function (index) {
|
87
|
+
var _cls2;
|
88
|
+
|
89
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
90
|
+
className: (0, _mobileUtils.cls)(prefixCls + "-index-bar-sidebar-item", (_cls2 = {}, _cls2[prefixCls + "-index-bar-sidebar-active"] = activeIndex === index, _cls2)),
|
91
|
+
key: index,
|
92
|
+
onTouchStart: function onTouchStart() {
|
93
|
+
return onClick(index);
|
94
|
+
},
|
95
|
+
"data-index": index
|
96
|
+
}, tipType === 'sweat' && isTouching && activeIndex === index && renderSideBarTip(index, 'sweat'), /*#__PURE__*/_react.default.createElement("div", {
|
97
|
+
className: prefixCls + "-index-bar-sidebar-item-wrapper"
|
98
|
+
}, renderSideBarItem(index)));
|
99
|
+
}));
|
100
|
+
|
101
|
+
return renderSideBar ? renderSideBar(node) : node;
|
102
|
+
}
|
@@ -0,0 +1,164 @@
|
|
1
|
+
.arco-index-bar {
|
2
|
+
position: relative;
|
3
|
+
background: white ;
|
4
|
+
overflow: hidden;
|
5
|
+
}
|
6
|
+
.arco-index-bar-container {
|
7
|
+
height: 100%;
|
8
|
+
overflow-y: auto;
|
9
|
+
}
|
10
|
+
.arco-index-bar-container::-webkit-scrollbar {
|
11
|
+
display: none;
|
12
|
+
}
|
13
|
+
.arco-index-bar-group-active {
|
14
|
+
color: #165dff ;
|
15
|
+
}
|
16
|
+
.arco-index-bar-group-title {
|
17
|
+
padding-left: 0.32rem ;
|
18
|
+
height: 0.48rem ;
|
19
|
+
background: #f7f8fa ;
|
20
|
+
font-size: 0.28rem ;
|
21
|
+
color: #86909c ;
|
22
|
+
display: -webkit-box;
|
23
|
+
display: -webkit-flex;
|
24
|
+
display: flex;
|
25
|
+
-webkit-box-align: center;
|
26
|
+
-webkit-align-items: center;
|
27
|
+
align-items: center;
|
28
|
+
}
|
29
|
+
.arco-index-bar-group-item {
|
30
|
+
height: 1.08rem ;
|
31
|
+
display: -webkit-box;
|
32
|
+
display: -webkit-flex;
|
33
|
+
display: flex;
|
34
|
+
-webkit-box-align: center;
|
35
|
+
-webkit-align-items: center;
|
36
|
+
align-items: center;
|
37
|
+
margin-left: 0.32rem ;
|
38
|
+
font-size: 0.32rem ;
|
39
|
+
}
|
40
|
+
.arco-index-bar-group-item:not(:last-child) {
|
41
|
+
position: relative;
|
42
|
+
border-width: 0;
|
43
|
+
}
|
44
|
+
.arco-index-bar-group-item:not(:last-child)::after {
|
45
|
+
content: '';
|
46
|
+
width: 100%;
|
47
|
+
height: 1PX;
|
48
|
+
position: absolute;
|
49
|
+
left: 0;
|
50
|
+
bottom: 0;
|
51
|
+
z-index: 1;
|
52
|
+
border-bottom-style: solid;
|
53
|
+
border-bottom-width: 1PX;
|
54
|
+
border-bottom-color: #e5e6eb;
|
55
|
+
box-sizing: border-box;
|
56
|
+
transform-origin: left bottom;
|
57
|
+
-webkit-transform-origin: left bottom;
|
58
|
+
pointer-events: none;
|
59
|
+
border-radius: 0;
|
60
|
+
}
|
61
|
+
@media (-webkit-min-device-pixel-ratio: 2), (min-device-pixel-ratio: 2) {
|
62
|
+
.arco-index-bar-group-item:not(:last-child)::after {
|
63
|
+
transform: scaleY(0.5);
|
64
|
+
-webkit-transform: scaleY(0.5);
|
65
|
+
border-radius: 0;
|
66
|
+
}
|
67
|
+
}
|
68
|
+
@media (-webkit-min-device-pixel-ratio: 3), (min-device-pixel-ratio: 3) {
|
69
|
+
.arco-index-bar-group-item:not(:last-child)::after {
|
70
|
+
transform: scaleY(0.33333333);
|
71
|
+
-webkit-transform: scaleY(0.33333333);
|
72
|
+
border-radius: 0;
|
73
|
+
}
|
74
|
+
}
|
75
|
+
.arco-index-bar-sidebar {
|
76
|
+
position: absolute;
|
77
|
+
z-index: 2;
|
78
|
+
right: 0;
|
79
|
+
top: 50%;
|
80
|
+
-webkit-transform: translateY(-50%) translateZ(0);
|
81
|
+
transform: translateY(-50%) translateZ(0);
|
82
|
+
-webkit-user-select: none;
|
83
|
+
user-select: none;
|
84
|
+
}
|
85
|
+
.arco-index-bar-sidebar-touching {
|
86
|
+
left: 0;
|
87
|
+
}
|
88
|
+
.arco-index-bar-sidebar-item {
|
89
|
+
display: -webkit-box;
|
90
|
+
display: -webkit-flex;
|
91
|
+
display: flex;
|
92
|
+
-webkit-box-pack: end;
|
93
|
+
-webkit-justify-content: flex-end;
|
94
|
+
justify-content: flex-end;
|
95
|
+
-webkit-box-align: center;
|
96
|
+
-webkit-align-items: center;
|
97
|
+
align-items: center;
|
98
|
+
position: relative;
|
99
|
+
padding: 0.04rem 0.16rem ;
|
100
|
+
cursor: pointer;
|
101
|
+
}
|
102
|
+
.arco-index-bar-sidebar-item-wrapper {
|
103
|
+
display: -webkit-inline-box;
|
104
|
+
display: -webkit-inline-flex;
|
105
|
+
display: inline-flex;
|
106
|
+
-webkit-box-align: center;
|
107
|
+
-webkit-align-items: center;
|
108
|
+
align-items: center;
|
109
|
+
-webkit-box-pack: center;
|
110
|
+
-webkit-justify-content: center;
|
111
|
+
justify-content: center;
|
112
|
+
width: 0.2rem ;
|
113
|
+
font-size: 0.2rem ;
|
114
|
+
line-height: 0.28rem ;
|
115
|
+
}
|
116
|
+
.arco-index-bar-sidebar-item:last-child {
|
117
|
+
padding-bottom: 0px;
|
118
|
+
}
|
119
|
+
.arco-index-bar-sidebar-active {
|
120
|
+
color: #165dff ;
|
121
|
+
}
|
122
|
+
.arco-index-bar-sidebar-sweat {
|
123
|
+
position: absolute;
|
124
|
+
height: 1rem ;
|
125
|
+
min-width: 1rem ;
|
126
|
+
line-height: 1rem ;
|
127
|
+
border-radius: 9999px;
|
128
|
+
text-align: center;
|
129
|
+
padding: 0 0.16rem ;
|
130
|
+
background: #323232 ;
|
131
|
+
right: 0.72rem ;
|
132
|
+
font-size: 0.48rem ;
|
133
|
+
color: white ;
|
134
|
+
}
|
135
|
+
.arco-index-bar-sidebar-sweat::before {
|
136
|
+
content: '';
|
137
|
+
position: absolute;
|
138
|
+
top: 0;
|
139
|
+
bottom: 0;
|
140
|
+
margin: auto;
|
141
|
+
right: -0.54rem ;
|
142
|
+
width: 0;
|
143
|
+
height: 0;
|
144
|
+
border: 0.36rem solid transparent ;
|
145
|
+
border: 18px solid transparent;
|
146
|
+
border-left-color: #323232 ;
|
147
|
+
border-radius: 4px;
|
148
|
+
}
|
149
|
+
.arco-index-bar-sidebar-toast {
|
150
|
+
position: absolute;
|
151
|
+
background: #323232 ;
|
152
|
+
color: white ;
|
153
|
+
left: 50%;
|
154
|
+
top: 50%;
|
155
|
+
min-width: 0.96rem ;
|
156
|
+
height: 0.96rem ;
|
157
|
+
line-height: 0.96rem ;
|
158
|
+
-webkit-transform: translate(-50%, -50%);
|
159
|
+
transform: translate(-50%, -50%);
|
160
|
+
text-align: center;
|
161
|
+
padding: 0 0.16rem ;
|
162
|
+
font-size: 0.48rem ;
|
163
|
+
border-radius: 0.08rem ;
|
164
|
+
}
|
@@ -0,0 +1,122 @@
|
|
1
|
+
@import '../../../style/mixin.less';
|
2
|
+
|
3
|
+
.@{prefix}-index-bar {
|
4
|
+
position: relative;
|
5
|
+
.use-var(background, index-bar-background);
|
6
|
+
overflow: hidden;
|
7
|
+
&-container {
|
8
|
+
height: 100%;
|
9
|
+
overflow-y: auto;
|
10
|
+
|
11
|
+
&::-webkit-scrollbar {
|
12
|
+
display: none;
|
13
|
+
}
|
14
|
+
}
|
15
|
+
|
16
|
+
&-group {
|
17
|
+
&-active {
|
18
|
+
.use-var(color, index-bar-group-active-color);
|
19
|
+
}
|
20
|
+
&-title {
|
21
|
+
.use-var(padding-left, index-bar-group-left-spacing);
|
22
|
+
.use-var(height, index-bar-group-title-height);
|
23
|
+
.use-var(background, index-bar-group-title-background);
|
24
|
+
.use-var(font-size, index-bar-group-title-font-size);
|
25
|
+
.use-var(color, index-bar-group-title-font-color);
|
26
|
+
display: flex;
|
27
|
+
align-items: center;
|
28
|
+
}
|
29
|
+
&-item {
|
30
|
+
.use-var(height, index-bar-group-item-height);
|
31
|
+
display: flex;
|
32
|
+
align-items: center;
|
33
|
+
.use-var(margin-left, index-bar-group-left-spacing);
|
34
|
+
.use-var(font-size, index-bar-group-item-font-size);
|
35
|
+
|
36
|
+
&:not(:last-child) {
|
37
|
+
.onepx-border-var(bottom, line-color);
|
38
|
+
}
|
39
|
+
}
|
40
|
+
}
|
41
|
+
|
42
|
+
&-sidebar {
|
43
|
+
&-touching {
|
44
|
+
left: 0;
|
45
|
+
}
|
46
|
+
position: absolute;
|
47
|
+
z-index: 2;
|
48
|
+
right: 0;
|
49
|
+
top: 50%;
|
50
|
+
transform: translateY(-50%) translateZ(0);
|
51
|
+
user-select: none;
|
52
|
+
|
53
|
+
&-item {
|
54
|
+
display: flex;
|
55
|
+
justify-content: flex-end;
|
56
|
+
align-items: center;
|
57
|
+
position: relative;
|
58
|
+
.use-var(padding, index-bar-sidebar-item-padding);
|
59
|
+
cursor: pointer;
|
60
|
+
|
61
|
+
&-wrapper {
|
62
|
+
display: inline-flex;
|
63
|
+
align-items: center;
|
64
|
+
justify-content: center;
|
65
|
+
.use-var(width, index-bar-sidebar-item-width);
|
66
|
+
.use-var(font-size, index-bar-sidebar-item-font-size);
|
67
|
+
.use-var(line-height, index-bar-sidebar-item-line-height);
|
68
|
+
}
|
69
|
+
|
70
|
+
&:last-child {
|
71
|
+
padding-bottom: 0px;
|
72
|
+
}
|
73
|
+
}
|
74
|
+
&-active {
|
75
|
+
.use-var(color, index-bar-sidebar-active-color);
|
76
|
+
}
|
77
|
+
|
78
|
+
&-sweat {
|
79
|
+
position: absolute;
|
80
|
+
.use-var(height, index-bar-sidebar-sweat-radius);
|
81
|
+
.use-var(min-width, index-bar-sidebar-sweat-radius);
|
82
|
+
.use-var(line-height, index-bar-sidebar-sweat-radius);
|
83
|
+
border-radius: 9999px;
|
84
|
+
text-align: center;
|
85
|
+
.use-var(padding, index-bar-sidebar-sweat-padding);
|
86
|
+
.use-var(background, index-bar-sidebar-sweat-background);
|
87
|
+
.use-var(right, index-bar-sidebar-sweat-right);
|
88
|
+
.use-var(font-size, index-bar-sidebar-sweat-font-size);
|
89
|
+
.use-var(color, index-bar-sidebar-sweat-color);
|
90
|
+
&::before {
|
91
|
+
content: '';
|
92
|
+
position: absolute;
|
93
|
+
top: 0;
|
94
|
+
bottom: 0;
|
95
|
+
margin: auto;
|
96
|
+
.use-var(right, index-bar-sidebar-sweat-triangle-position);
|
97
|
+
width: 0;
|
98
|
+
height: 0;
|
99
|
+
.use-var(border, index-bar-sidebar-sweat-triangle-border);
|
100
|
+
border: 18px solid transparent;
|
101
|
+
.use-var(border-left-color, index-bar-sidebar-sweat-background);
|
102
|
+
border-radius: 4px;
|
103
|
+
}
|
104
|
+
}
|
105
|
+
|
106
|
+
&-toast {
|
107
|
+
position: absolute;
|
108
|
+
.use-var(background, index-bar-sidebar-toast-background);
|
109
|
+
.use-var(color, index-bar-sidebar-toast-color);
|
110
|
+
left: 50%;
|
111
|
+
top: 50%;
|
112
|
+
.use-var(min-width, index-bar-sidebar-toast-height);
|
113
|
+
.use-var(height, index-bar-sidebar-toast-height);
|
114
|
+
.use-var(line-height, index-bar-sidebar-toast-height);
|
115
|
+
transform: translate(-50%, -50%);
|
116
|
+
text-align: center;
|
117
|
+
.use-var(padding, index-bar-sidebar-toast-padding);
|
118
|
+
.use-var(font-size, index-bar-sidebar-toast-font-size);
|
119
|
+
.use-var(border-radius, index-bar-sidebar-toast-radius);
|
120
|
+
}
|
121
|
+
}
|
122
|
+
}
|