@arco-design/mobile-react 2.26.0 → 2.27.1
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 +29 -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 +274 -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 +1172 -444
- package/dist/index.min.js +5 -5
- 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 +253 -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,15 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import type { IndexBarBaseData, IndexBarProps, IndexBarRef } from './type';
|
3
|
+
export type { IndexBarProps, IndexBarRef, IndexBarGroupProps, IndexBarGroupRef, IndexBarChangeTrigger, IndexBarIndexType, IndexBarTipType, } from './type';
|
4
|
+
declare const _default: React.ForwardRefExoticComponent<IndexBarProps<IndexBarBaseData> & React.RefAttributes<IndexBarRef>> & {
|
5
|
+
Group: React.ForwardRefExoticComponent<import("./type").IndexBarGroupProps<IndexBarBaseData> & React.RefAttributes<import("./type").IndexBarGroupRef>>;
|
6
|
+
};
|
7
|
+
/**
|
8
|
+
* 索引栏组件
|
9
|
+
* @en IndexBar component
|
10
|
+
* @type 导航
|
11
|
+
* @type_en Navigation
|
12
|
+
* @name 索引栏
|
13
|
+
* @name_en SearchBar
|
14
|
+
*/
|
15
|
+
export default _default;
|
@@ -0,0 +1,274 @@
|
|
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 _lodash = _interopRequireDefault(require("lodash.throttle"));
|
11
|
+
|
12
|
+
var _react = _interopRequireWildcard(require("react"));
|
13
|
+
|
14
|
+
var _contextProvider = require("../context-provider");
|
15
|
+
|
16
|
+
var _context = require("./context");
|
17
|
+
|
18
|
+
var _group = require("./group");
|
19
|
+
|
20
|
+
var _sideBar = require("./side-bar");
|
21
|
+
|
22
|
+
var _utils = require("./utils");
|
23
|
+
|
24
|
+
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); }
|
25
|
+
|
26
|
+
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; }
|
27
|
+
|
28
|
+
var IndexBar = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
29
|
+
var _props$className = props.className,
|
30
|
+
className = _props$className === void 0 ? '' : _props$className,
|
31
|
+
style = props.style,
|
32
|
+
children = props.children,
|
33
|
+
_props$sticky = props.sticky,
|
34
|
+
sticky = _props$sticky === void 0 ? true : _props$sticky,
|
35
|
+
_props$groups = props.groups,
|
36
|
+
groups = _props$groups === void 0 ? [] : _props$groups,
|
37
|
+
_props$tipType = props.tipType,
|
38
|
+
tipType = _props$tipType === void 0 ? 'toast' : _props$tipType,
|
39
|
+
defaultIndex = props.defaultIndex,
|
40
|
+
scrollBezier = props.scrollBezier,
|
41
|
+
_props$scrollDuration = props.scrollDuration,
|
42
|
+
scrollDuration = _props$scrollDuration === void 0 ? 0 : _props$scrollDuration,
|
43
|
+
_props$disableSidebar = props.disableSidebar,
|
44
|
+
disableSidebar = _props$disableSidebar === void 0 ? false : _props$disableSidebar,
|
45
|
+
onChange = props.onChange,
|
46
|
+
onGroupItemClick = props.onGroupItemClick,
|
47
|
+
renderSideBar = props.renderSideBar,
|
48
|
+
renderSideBarItem = props.renderSideBarItem,
|
49
|
+
renderTip = props.renderTip,
|
50
|
+
renderStickyItem = props.renderStickyItem,
|
51
|
+
renderGroupItem = props.renderGroupItem; // 最外层dom元素的ref
|
52
|
+
|
53
|
+
var domRef = (0, _react.useRef)(null); // 所有group的容器dom,domRef的内容就是contanerRef和sidebar的内容
|
54
|
+
|
55
|
+
var containerRef = (0, _react.useRef)(null); // 过滤掉jsx写法中,奇怪的child
|
56
|
+
|
57
|
+
var formatChildren = (0, _utils.filterValidIndexBarChild)(children); // 所有的索引内容,优先从props.groups中获取,再从formatChildren中获取
|
58
|
+
|
59
|
+
var indexes = (0, _react.useMemo)(function () {
|
60
|
+
if (groups.length) {
|
61
|
+
return groups.map(function (group) {
|
62
|
+
return group.index;
|
63
|
+
});
|
64
|
+
}
|
65
|
+
|
66
|
+
return formatChildren.map(function (child) {
|
67
|
+
return child.props.index;
|
68
|
+
});
|
69
|
+
}, [children, groups]);
|
70
|
+
var groupRefs = (0, _react.useRef)({}); // 当前激活的Index
|
71
|
+
|
72
|
+
var _useState = (0, _react.useState)(function () {
|
73
|
+
return defaultIndex != null ? defaultIndex : indexes == null ? void 0 : indexes[0];
|
74
|
+
}),
|
75
|
+
activeIndex = _useState[0],
|
76
|
+
setActiveIndex = _useState[1]; // 给IndexBarGroup用的上下文,主要是为了兼容jsx的写法
|
77
|
+
|
78
|
+
|
79
|
+
var contextValue = (0, _react.useMemo)(function () {
|
80
|
+
return {
|
81
|
+
sticky: sticky,
|
82
|
+
getScrollContainer: function getScrollContainer() {
|
83
|
+
return containerRef.current;
|
84
|
+
},
|
85
|
+
activeIndex: activeIndex,
|
86
|
+
updateRef: function updateRef(groupIndex, stickyRef) {
|
87
|
+
groupRefs.current[groupIndex] = stickyRef;
|
88
|
+
}
|
89
|
+
};
|
90
|
+
}, [sticky, activeIndex]); // 用户是否正在触碰sidebar, 如果为true的话,禁用handleScroll的处理
|
91
|
+
|
92
|
+
var isScrollHandlerDisabledRef = (0, _react.useRef)(false);
|
93
|
+
|
94
|
+
var handleChangeActiveIndex = function handleChangeActiveIndex(index, type) {
|
95
|
+
setActiveIndex(function (oldActiveIndex) {
|
96
|
+
var newActiveIndex = (0, _utils.getFormatIndex)(index, oldActiveIndex); // 和上一次激活的acitveIndex不同,再触发onChange事件
|
97
|
+
|
98
|
+
if (newActiveIndex !== oldActiveIndex) {
|
99
|
+
onChange == null ? void 0 : onChange(newActiveIndex, type);
|
100
|
+
}
|
101
|
+
|
102
|
+
return newActiveIndex;
|
103
|
+
});
|
104
|
+
}; // 要滚动到哪个指定的index
|
105
|
+
|
106
|
+
|
107
|
+
var handleScrollIntoIndex = function handleScrollIntoIndex(params) {
|
108
|
+
var index = params.index,
|
109
|
+
type = params.type,
|
110
|
+
_params$rightNow = params.rightNow,
|
111
|
+
rightNow = _params$rightNow === void 0 ? false : _params$rightNow; // 不传index默认走第一个index
|
112
|
+
|
113
|
+
var formatIndex = index != null ? index : indexes == null ? void 0 : indexes[0];
|
114
|
+
var containerDom = containerRef.current;
|
115
|
+
|
116
|
+
if (!(0, _utils.isValidIndex)(index) || !containerDom) {
|
117
|
+
return;
|
118
|
+
} // 寻找Index对应的groupDom
|
119
|
+
|
120
|
+
|
121
|
+
var groupDom = (0, _utils.getGroupDomFromIndex)(containerDom, formatIndex);
|
122
|
+
|
123
|
+
if (groupDom) {
|
124
|
+
handleChangeActiveIndex(formatIndex, type);
|
125
|
+
var duration = rightNow ? 0 : scrollDuration;
|
126
|
+
var targetScrollTop = groupDom.offsetTop; // 将屏幕滚动到groupDom
|
127
|
+
// 手动触发需要禁用handleScroll事件
|
128
|
+
|
129
|
+
if (type === 'manual') {
|
130
|
+
isScrollHandlerDisabledRef.current = true;
|
131
|
+
setTimeout(function () {
|
132
|
+
isScrollHandlerDisabledRef.current = false;
|
133
|
+
}, duration);
|
134
|
+
}
|
135
|
+
|
136
|
+
if (duration > 0) {
|
137
|
+
(0, _mobileUtils.scrollWithAnimation)(containerDom.scrollTop, targetScrollTop, function (top) {
|
138
|
+
return containerDom.scrollTop = top;
|
139
|
+
}, duration, scrollBezier);
|
140
|
+
} else {
|
141
|
+
containerDom.scrollTop = targetScrollTop;
|
142
|
+
}
|
143
|
+
}
|
144
|
+
};
|
145
|
+
|
146
|
+
(0, _react.useImperativeHandle)(ref, function () {
|
147
|
+
return {
|
148
|
+
dom: domRef.current,
|
149
|
+
scrollToIndex: function scrollToIndex(index, rightNow) {
|
150
|
+
if ((0, _utils.isValidIndex)(index)) {
|
151
|
+
handleScrollIntoIndex({
|
152
|
+
index: index,
|
153
|
+
rightNow: rightNow,
|
154
|
+
type: 'manual'
|
155
|
+
});
|
156
|
+
}
|
157
|
+
},
|
158
|
+
recalculatePosition: function recalculatePosition(targetIndex) {
|
159
|
+
var formatIndex = targetIndex != null ? targetIndex : activeIndex;
|
160
|
+
|
161
|
+
if (formatIndex) {
|
162
|
+
var targetStickyRef = groupRefs.current[formatIndex];
|
163
|
+
|
164
|
+
if (targetStickyRef && targetStickyRef.recalculatePosition) {
|
165
|
+
targetStickyRef.recalculatePosition();
|
166
|
+
}
|
167
|
+
}
|
168
|
+
}
|
169
|
+
};
|
170
|
+
});
|
171
|
+
|
172
|
+
var renderChildren = function renderChildren() {
|
173
|
+
if (formatChildren.length) {
|
174
|
+
return formatChildren;
|
175
|
+
}
|
176
|
+
|
177
|
+
return groups == null ? void 0 : groups.map(function (group) {
|
178
|
+
return /*#__PURE__*/_react.default.createElement(_group.IndexBarGroup, {
|
179
|
+
index: group.index,
|
180
|
+
key: group.index,
|
181
|
+
list: group.list,
|
182
|
+
onGroupItemClick: onGroupItemClick,
|
183
|
+
renderGroupItem: renderGroupItem,
|
184
|
+
renderStickyItem: renderStickyItem
|
185
|
+
});
|
186
|
+
});
|
187
|
+
};
|
188
|
+
|
189
|
+
(0, _react.useEffect)(function () {
|
190
|
+
var _containerRef$current;
|
191
|
+
|
192
|
+
var handleScroll = (0, _lodash.default)(function () {
|
193
|
+
// 用户正在触碰sidebar和手动触发scroll时禁用滚动事件的处理
|
194
|
+
if (!containerRef.current || isScrollHandlerDisabledRef.current) {
|
195
|
+
return;
|
196
|
+
} // 根据滚动的距离,获取处于屏幕最顶部的group是哪个
|
197
|
+
|
198
|
+
|
199
|
+
var scrollTop = containerRef.current.scrollTop;
|
200
|
+
|
201
|
+
for (var i = 0; i < containerRef.current.children.length; i++) {
|
202
|
+
var child = containerRef.current.children[i];
|
203
|
+
|
204
|
+
if (!child || !child.dataset || typeof child.dataset.index === 'undefined') {
|
205
|
+
continue;
|
206
|
+
}
|
207
|
+
|
208
|
+
if (child.offsetTop + child.clientHeight >= scrollTop) {
|
209
|
+
handleChangeActiveIndex(child.dataset.index, 'swipe');
|
210
|
+
break;
|
211
|
+
}
|
212
|
+
}
|
213
|
+
}, 100); // 页面挂载时,如果是传入了defaultIndex,则滚动到对应位置
|
214
|
+
|
215
|
+
if (activeIndex) {
|
216
|
+
handleScrollIntoIndex({
|
217
|
+
index: activeIndex,
|
218
|
+
rightNow: true,
|
219
|
+
type: 'manual'
|
220
|
+
});
|
221
|
+
}
|
222
|
+
|
223
|
+
(_containerRef$current = containerRef.current) == null ? void 0 : _containerRef$current.addEventListener('scroll', handleScroll);
|
224
|
+
return function () {
|
225
|
+
var _containerRef$current2;
|
226
|
+
|
227
|
+
(_containerRef$current2 = containerRef.current) == null ? void 0 : _containerRef$current2.removeEventListener('scroll', handleScroll);
|
228
|
+
};
|
229
|
+
}, []);
|
230
|
+
return /*#__PURE__*/_react.default.createElement(_contextProvider.ContextLayout, null, function (_ref) {
|
231
|
+
var prefixCls = _ref.prefixCls;
|
232
|
+
return /*#__PURE__*/_react.default.createElement(_context.IndexBarContext.Provider, {
|
233
|
+
value: contextValue
|
234
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
235
|
+
className: (0, _mobileUtils.cls)(prefixCls + "-index-bar", className),
|
236
|
+
style: style,
|
237
|
+
ref: domRef
|
238
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
239
|
+
className: prefixCls + "-index-bar-container",
|
240
|
+
ref: containerRef
|
241
|
+
}, renderChildren()), !disableSidebar && /*#__PURE__*/_react.default.createElement(_sideBar.IndexBarSideBar, {
|
242
|
+
tipType: tipType,
|
243
|
+
activeIndex: activeIndex,
|
244
|
+
prefixCls: prefixCls,
|
245
|
+
indexes: indexes,
|
246
|
+
onTouching: function onTouching(isTouching) {
|
247
|
+
return isScrollHandlerDisabledRef.current = isTouching;
|
248
|
+
},
|
249
|
+
onClick: function onClick(newIndex) {
|
250
|
+
return handleScrollIntoIndex({
|
251
|
+
index: newIndex,
|
252
|
+
type: 'sidebar'
|
253
|
+
});
|
254
|
+
},
|
255
|
+
renderSideBar: renderSideBar,
|
256
|
+
renderSideBarItem: renderSideBarItem,
|
257
|
+
renderTip: renderTip
|
258
|
+
})));
|
259
|
+
});
|
260
|
+
});
|
261
|
+
/**
|
262
|
+
* 索引栏组件
|
263
|
+
* @en IndexBar component
|
264
|
+
* @type 导航
|
265
|
+
* @type_en Navigation
|
266
|
+
* @name 索引栏
|
267
|
+
* @name_en SearchBar
|
268
|
+
*/
|
269
|
+
|
270
|
+
var _default = (0, _mobileUtils.componentWrapper)(IndexBar, {
|
271
|
+
Group: _group.IndexBarGroup
|
272
|
+
});
|
273
|
+
|
274
|
+
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
|
+
}
|