@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,195 @@
|
|
1
|
+
import React, { CSSProperties, ReactElement, ReactNode } from 'react';
|
2
|
+
import { StickyRef } from '../sticky';
|
3
|
+
import { BaseRef } from '../_helpers';
|
4
|
+
export declare type IndexBarIndexType = string | number;
|
5
|
+
export interface IndexBarBaseData {
|
6
|
+
/**
|
7
|
+
* 内容
|
8
|
+
* @en content
|
9
|
+
*/
|
10
|
+
content: ReactNode;
|
11
|
+
}
|
12
|
+
interface IndexBarGroupItem<Data extends IndexBarBaseData> {
|
13
|
+
/**
|
14
|
+
* IndexBarGroup对应的索引
|
15
|
+
* @en Index corresponding to IndexBarGroup
|
16
|
+
*/
|
17
|
+
index: IndexBarIndexType;
|
18
|
+
/**
|
19
|
+
* IndexBarGroup中要渲染的列表数据,如果已经传递了children这个属性,则list这个属性不会生效
|
20
|
+
* @en The list data to be rendered in IndexBarGroup, if the children attribute has been passed, the list attribute will not take effect
|
21
|
+
*/
|
22
|
+
list?: Data[];
|
23
|
+
}
|
24
|
+
export declare type IndexBarTipType = 'none' | 'sweat' | 'toast';
|
25
|
+
export declare type IndexBarChangeTrigger = 'swipe' | 'manual' | 'sidebar';
|
26
|
+
export interface IndexBarScrollParams {
|
27
|
+
index: IndexBarIndexType;
|
28
|
+
type: IndexBarChangeTrigger;
|
29
|
+
rightNow?: boolean;
|
30
|
+
}
|
31
|
+
export interface IndexBarSideBarProps {
|
32
|
+
tipType: IndexBarTipType;
|
33
|
+
indexes: IndexBarIndexType[];
|
34
|
+
prefixCls?: string;
|
35
|
+
onTouching: (isTouching: boolean) => void;
|
36
|
+
onClick: (index: IndexBarIndexType) => void;
|
37
|
+
activeIndex?: IndexBarIndexType;
|
38
|
+
renderSideBarItem?: (index: IndexBarIndexType) => ReactNode;
|
39
|
+
renderSideBar?: (Content: ReactNode) => ReactElement;
|
40
|
+
renderTip?: (index: IndexBarIndexType) => ReactNode;
|
41
|
+
}
|
42
|
+
export interface IndexBarGroupProps<Data extends IndexBarBaseData> extends IndexBarGroupItem<Data> {
|
43
|
+
/**
|
44
|
+
* 自定义类名
|
45
|
+
* @en Custom classname
|
46
|
+
*/
|
47
|
+
className?: string;
|
48
|
+
/**
|
49
|
+
* 自定义样式
|
50
|
+
* @en Custom stylesheet
|
51
|
+
*/
|
52
|
+
style?: CSSProperties;
|
53
|
+
/**
|
54
|
+
* 自定义内容的渲染,有自定义内容优先渲染自定义内容,否则渲染list传递的数据
|
55
|
+
* @en Rendering of custom content, if there is custom content, the custom content is rendered first, otherwise the data passed by the list is rendered
|
56
|
+
*/
|
57
|
+
children?: ReactNode;
|
58
|
+
/**
|
59
|
+
* 自定义提取List的key作为列表渲染的key,默认选取listItem的所在数组位置
|
60
|
+
* @en Customize the extracted key of the List as the key for list rendering, and select the array position where the listItem is located by default
|
61
|
+
*/
|
62
|
+
listKey?: (data: Data, listItemIndex: number) => IndexBarIndexType;
|
63
|
+
/**
|
64
|
+
* IndexBar.Group中某个子项被点击时的回调
|
65
|
+
* @en Callback when a child item in IndexBar.Group is clicked
|
66
|
+
*/
|
67
|
+
onGroupItemClick?: (index: IndexBarIndexType, itemData: Data, itemIndex: number) => void;
|
68
|
+
/**
|
69
|
+
* 自定义IndexBar.Group的索引标题内容渲染
|
70
|
+
* @en Customize IndexBar.Group's index title content rendering
|
71
|
+
*/
|
72
|
+
renderStickyItem?: (index: IndexBarIndexType) => ReactNode;
|
73
|
+
/**
|
74
|
+
* 自定义IndexBar.Group的子项内容渲染
|
75
|
+
* @en Customize the rendering of sub-items of IndexBar.Group
|
76
|
+
*/
|
77
|
+
renderGroupItem?: (index: IndexBarIndexType, itemData: Data, itemIndex: number) => ReactNode;
|
78
|
+
}
|
79
|
+
export interface IndexBarGroupRef extends BaseRef {
|
80
|
+
}
|
81
|
+
export interface IndexBarProps<Data extends IndexBarBaseData> {
|
82
|
+
/**
|
83
|
+
* 自定义类名
|
84
|
+
* @en Custom classname
|
85
|
+
*/
|
86
|
+
className?: string;
|
87
|
+
/**
|
88
|
+
* 自定义样式
|
89
|
+
* @en Custom stylesheet
|
90
|
+
*/
|
91
|
+
style?: React.CSSProperties;
|
92
|
+
/**
|
93
|
+
* 默认要激活的索引
|
94
|
+
* @en Index to activate by default
|
95
|
+
*/
|
96
|
+
defaultIndex?: IndexBarIndexType;
|
97
|
+
/**
|
98
|
+
* 是否开启侧边栏功能
|
99
|
+
* @en Whether to enable the sidebar function
|
100
|
+
* @default false
|
101
|
+
*/
|
102
|
+
disableSidebar?: boolean;
|
103
|
+
/**
|
104
|
+
* 是否开启索引的自动吸顶效果
|
105
|
+
* @en Whether to enable the automatic ceiling effect of the index
|
106
|
+
* @default true
|
107
|
+
*/
|
108
|
+
sticky?: boolean;
|
109
|
+
/**
|
110
|
+
* 索引栏内容
|
111
|
+
* @en IndexBar contents
|
112
|
+
*/
|
113
|
+
groups?: IndexBarGroupItem<Data>[];
|
114
|
+
/**
|
115
|
+
* 自定义内容的渲染,内容必须是IndexBar.Group组件
|
116
|
+
* @en Rendering of custom content, the content must be an IndexBar.Group component
|
117
|
+
*/
|
118
|
+
children?: ReactNode;
|
119
|
+
/**
|
120
|
+
* 侧边栏索引提示的样式类型 - sweat 水滴形 - toast 轻提示 - none 关闭提示
|
121
|
+
* @en Style type of sidebar index hint - sweat: teardrop - toast: light hint - none: turn off hint
|
122
|
+
* @default "toast"
|
123
|
+
*/
|
124
|
+
tipType?: IndexBarTipType;
|
125
|
+
/**
|
126
|
+
* 手动调用scrollToIndex时,滚动动画的执行时间
|
127
|
+
* @en Execution time of scrolling animation when scrollToIndex is called manually
|
128
|
+
* @default 0
|
129
|
+
*/
|
130
|
+
scrollDuration?: number;
|
131
|
+
/**
|
132
|
+
* 手动调用scrollToIndex时,滚动的动画曲线
|
133
|
+
* @en When scrollToIndex is called manually, the scrolling animation curve
|
134
|
+
*/
|
135
|
+
scrollBezier?: [number, number, number, number];
|
136
|
+
/**
|
137
|
+
* 激活的索引改变时的回调,第一个参数是新的索引,第二个参数是改变方式:- swipe 手动滑动页面触发变化 - sidebar 侧边栏点击触发变化 - manual 手动调用scrollToIndex触发
|
138
|
+
* @en Callback when the active index changes, the first parameter is the new index, and the second parameter is the change method: - swipe: triggers the change by manually sliding the page - sidebar: triggers the change by clicking on the sidebar - manual: triggers by manually calling scrollToIndex
|
139
|
+
*/
|
140
|
+
onChange?: (index: IndexBarIndexType, trigger: IndexBarChangeTrigger) => void;
|
141
|
+
/**
|
142
|
+
* IndexBar.Group中某个子项被点击时的回调,使用JSX的写法时该回调不会生效,请在IndexBar.Group上绑定对应属性
|
143
|
+
* @en The callback when a sub-item in IndexBar.Group is clicked, the callback will not take effect when using JSX writing, please bind the corresponding property on IndexBar.Group
|
144
|
+
*/
|
145
|
+
onGroupItemClick?: (index: IndexBarIndexType, itemData: Data, itemIndex: number) => void;
|
146
|
+
/**
|
147
|
+
* 自定义侧边栏每个子项的内容渲染
|
148
|
+
* @en Customize the content rendering of each sub-item in the sidebar
|
149
|
+
*/
|
150
|
+
renderSideBarItem?: (index: IndexBarIndexType) => ReactNode;
|
151
|
+
/**
|
152
|
+
* 自定义侧边栏渲染
|
153
|
+
* @en Custom sidebar rendering
|
154
|
+
*/
|
155
|
+
renderSideBar?: (Content: ReactNode) => ReactElement;
|
156
|
+
/**
|
157
|
+
* 自定义使用侧边栏改变索引时,渲染提示的内容
|
158
|
+
* @en Customize the content of the rendering prompt when changing the index using the sidebar
|
159
|
+
*/
|
160
|
+
renderTip?: (index: IndexBarIndexType) => ReactNode;
|
161
|
+
/**
|
162
|
+
* 自定义IndexBar.Group的索引标题内容渲染,使用JSX的写法时该回调不会生效,请在IndexBar.Group上绑定对应属性
|
163
|
+
* @en Customize the rendering of the index title content of IndexBar.Group. When using JSX writing, the callback will not take effect. Please bind the corresponding property on IndexBar.Group
|
164
|
+
*/
|
165
|
+
renderStickyItem?: (index: IndexBarIndexType) => ReactNode;
|
166
|
+
/**
|
167
|
+
* 自定义IndexBar.Group的子项内容渲染,使用JSX的写法时该回调不会生效,请在IndexBar.Group上绑定对应属性
|
168
|
+
* @en Customize the rendering of sub-items of IndexBar.Group. This callback will not take effect when using JSX. Please bind the corresponding properties on IndexBar.Group
|
169
|
+
*/
|
170
|
+
renderGroupItem?: (index: IndexBarIndexType, itemData: Data, itemIndex: number) => ReactNode;
|
171
|
+
}
|
172
|
+
export interface IndexBarRef {
|
173
|
+
/**
|
174
|
+
* 最外层 DOM 元素
|
175
|
+
* @en The outer DOM element of the component
|
176
|
+
*/
|
177
|
+
dom: HTMLDivElement | null;
|
178
|
+
/**
|
179
|
+
* 手动滚动到指定的索引位置
|
180
|
+
* @en Manually scroll to the specified index position
|
181
|
+
*/
|
182
|
+
scrollToIndex: (index?: IndexBarIndexType, rightNow?: boolean) => void;
|
183
|
+
/**
|
184
|
+
* 局部滚动模式下,如果容器外部还有嵌套滚动,可主动调用此方法,让 sticky 的元素主动更新 fixed 位置
|
185
|
+
* @en In the local scrolling mode, if there is nested scrolling outside the container, this method can be actively called to make the sticky element actively update the fixed position
|
186
|
+
*/
|
187
|
+
recalculatePosition: (index?: IndexBarIndexType) => void;
|
188
|
+
}
|
189
|
+
export interface IndexBarContext {
|
190
|
+
sticky: boolean;
|
191
|
+
getScrollContainer: () => HTMLDivElement | null;
|
192
|
+
activeIndex?: IndexBarIndexType;
|
193
|
+
updateRef: (index: IndexBarIndexType, ref: StickyRef) => void;
|
194
|
+
}
|
195
|
+
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,6 @@
|
|
1
|
+
import { ReactElement, ReactNode } from 'react';
|
2
|
+
import { IndexBarIndexType } from './type';
|
3
|
+
export declare function filterValidIndexBarChild(children: ReactNode): ReactElement<any, string | ((props: any) => ReactElement<any, any> | null) | (new (props: any) => import("react").Component<any, any, any>)>[];
|
4
|
+
export declare function getFormatIndex(index: IndexBarIndexType, activeIndex: IndexBarIndexType | undefined): string | number;
|
5
|
+
export declare function isValidIndex(index: unknown): index is IndexBarIndexType;
|
6
|
+
export declare function getGroupDomFromIndex(containerDom: HTMLDivElement, activeIndex: IndexBarIndexType): HTMLDivElement | null;
|
@@ -0,0 +1,53 @@
|
|
1
|
+
import { Children, isValidElement } from 'react';
|
2
|
+
import { IndexBarGroup } from './group';
|
3
|
+
export function filterValidIndexBarChild(children) {
|
4
|
+
var validChildren = [];
|
5
|
+
Children.forEach(children, function (child) {
|
6
|
+
if (! /*#__PURE__*/isValidElement(child) || child.type !== IndexBarGroup) {
|
7
|
+
console.warn('<IndexBar /> only accept <IndexBar.Group /> as the children');
|
8
|
+
return;
|
9
|
+
}
|
10
|
+
|
11
|
+
validChildren.push(child);
|
12
|
+
});
|
13
|
+
return validChildren;
|
14
|
+
} // index有可能是number或者string,但是绑在data-index的attr上后
|
15
|
+
// 通过滑动事件得到的都是string,需要处理下
|
16
|
+
|
17
|
+
export function getFormatIndex(index, activeIndex) {
|
18
|
+
var activeIndexType = typeof activeIndex;
|
19
|
+
var indexType = typeof index;
|
20
|
+
|
21
|
+
if (indexType === activeIndexType) {
|
22
|
+
return index;
|
23
|
+
}
|
24
|
+
|
25
|
+
if (activeIndexType === 'number') {
|
26
|
+
return Number(index);
|
27
|
+
}
|
28
|
+
|
29
|
+
return index.toString();
|
30
|
+
}
|
31
|
+
export function isValidIndex(index) {
|
32
|
+
return typeof index === 'number' || typeof index === 'string';
|
33
|
+
}
|
34
|
+
export function getGroupDomFromIndex(containerDom, activeIndex) {
|
35
|
+
var targetDom = null;
|
36
|
+
var containerChildren = containerDom.children;
|
37
|
+
|
38
|
+
for (var i = 0; i < containerChildren.length; i++) {
|
39
|
+
var dom = containerChildren[i];
|
40
|
+
var dataset = dom == null ? void 0 : dom.dataset;
|
41
|
+
|
42
|
+
if (dataset && dataset.index) {
|
43
|
+
var formatIndex = getFormatIndex(dataset.index, activeIndex);
|
44
|
+
|
45
|
+
if (formatIndex === activeIndex) {
|
46
|
+
targetDom = dom;
|
47
|
+
break;
|
48
|
+
}
|
49
|
+
}
|
50
|
+
}
|
51
|
+
|
52
|
+
return targetDom;
|
53
|
+
}
|
package/esm/index.d.ts
CHANGED
@@ -26,6 +26,8 @@ export { default as Image } from './image';
|
|
26
26
|
export { default as ShowMonitor } from './show-monitor';
|
27
27
|
export { default as ImagePicker } from './image-picker';
|
28
28
|
export { default as ImagePreview } from './image-preview';
|
29
|
+
export { default as IndexBar } from './index-bar';
|
30
|
+
export { default as Keyboard } from './keyboard';
|
29
31
|
export { default as LoadMore } from './load-more';
|
30
32
|
export { default as Loading } from './loading';
|
31
33
|
export { default as Masking } from './masking';
|
package/esm/index.js
CHANGED
@@ -26,6 +26,8 @@ export { default as Image } from './image';
|
|
26
26
|
export { default as ShowMonitor } from './show-monitor';
|
27
27
|
export { default as ImagePicker } from './image-picker';
|
28
28
|
export { default as ImagePreview } from './image-preview';
|
29
|
+
export { default as IndexBar } from './index-bar';
|
30
|
+
export { default as Keyboard } from './keyboard';
|
29
31
|
export { default as LoadMore } from './load-more';
|
30
32
|
export { default as Loading } from './loading';
|
31
33
|
export { default as Masking } from './masking';
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { KeyboardProps, KeyboardRef } from './type';
|
3
|
+
export * from './type';
|
4
|
+
/**
|
5
|
+
* 数字键盘组件
|
6
|
+
* @en Keyboard component
|
7
|
+
* @type 数据录入
|
8
|
+
* @type_en Data Entry
|
9
|
+
* @name 数字键盘
|
10
|
+
* @name_en Keyboard
|
11
|
+
*/
|
12
|
+
declare const Keyboard: React.ForwardRefExoticComponent<KeyboardProps & React.RefAttributes<KeyboardRef>>;
|
13
|
+
export default Keyboard;
|
@@ -0,0 +1,243 @@
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
|
3
|
+
var _excluded = ["normalKeyClass", "normalKeyStyle", "className", "style", "type", "randomOrder", "title", "rightColumns", "confirmClosable", "confirmButton", "deleteButton", "keyboardButton", "close", "onConfirm", "onDelete", "onChange"];
|
4
|
+
import { cls, defaultLocale } from '@arco-design/mobile-utils';
|
5
|
+
import React, { useRef, forwardRef, useImperativeHandle, useMemo, useCallback, useEffect, useContext } from 'react';
|
6
|
+
import { GlobalContext } from '../context-provider';
|
7
|
+
import { IconKeyboard, IconKeyboardDelete } from '../icon';
|
8
|
+
import Popup from '../popup';
|
9
|
+
export * from './type'; // 键盘乱序
|
10
|
+
// @en let keyboard random
|
11
|
+
|
12
|
+
var makeArrayRandom = function makeArrayRandom(targetArray) {
|
13
|
+
var randomFn = function randomFn() {
|
14
|
+
return Math.random() - 0.5;
|
15
|
+
};
|
16
|
+
|
17
|
+
return targetArray.sort(randomFn);
|
18
|
+
};
|
19
|
+
|
20
|
+
var splitArray = function splitArray(target) {
|
21
|
+
return target.reduce(function (acc, cur) {
|
22
|
+
if (!acc[acc.length - 1] || acc[acc.length - 1].length >= 3) {
|
23
|
+
acc.push([]);
|
24
|
+
}
|
25
|
+
|
26
|
+
acc[acc.length - 1].push(cur);
|
27
|
+
return acc;
|
28
|
+
}, []);
|
29
|
+
}; // 纯数字类字符
|
30
|
+
// @en Pure numeric characters
|
31
|
+
|
32
|
+
|
33
|
+
var contentArray = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0];
|
34
|
+
/**
|
35
|
+
* 数字键盘组件
|
36
|
+
* @en Keyboard component
|
37
|
+
* @type 数据录入
|
38
|
+
* @type_en Data Entry
|
39
|
+
* @name 数字键盘
|
40
|
+
* @name_en Keyboard
|
41
|
+
*/
|
42
|
+
|
43
|
+
var Keyboard = /*#__PURE__*/forwardRef(function (props, ref) {
|
44
|
+
var normalKeyClass = props.normalKeyClass,
|
45
|
+
normalKeyStyle = props.normalKeyStyle,
|
46
|
+
_props$className = props.className,
|
47
|
+
className = _props$className === void 0 ? '' : _props$className,
|
48
|
+
style = props.style,
|
49
|
+
_props$type = props.type,
|
50
|
+
type = _props$type === void 0 ? 'number' : _props$type,
|
51
|
+
_props$randomOrder = props.randomOrder,
|
52
|
+
randomOrder = _props$randomOrder === void 0 ? false : _props$randomOrder,
|
53
|
+
title = props.title,
|
54
|
+
rightColumns = props.rightColumns,
|
55
|
+
confirmClosable = props.confirmClosable,
|
56
|
+
confirmButton = props.confirmButton,
|
57
|
+
deleteButton = props.deleteButton,
|
58
|
+
keyboardButton = props.keyboardButton,
|
59
|
+
close = props.close,
|
60
|
+
onConfirm = props.onConfirm,
|
61
|
+
onDelete = props.onDelete,
|
62
|
+
onChange = props.onChange,
|
63
|
+
resetProps = _objectWithoutPropertiesLoose(props, _excluded);
|
64
|
+
|
65
|
+
var popupRef = useRef(null);
|
66
|
+
var keyboardRef = useRef(null);
|
67
|
+
|
68
|
+
var _useContext = useContext(GlobalContext),
|
69
|
+
prefixCls = _useContext.prefixCls,
|
70
|
+
_useContext$locale = _useContext.locale,
|
71
|
+
locale = _useContext$locale === void 0 ? defaultLocale : _useContext$locale;
|
72
|
+
|
73
|
+
var prefix = prefixCls + "-keyboard"; // 3x4键盘的按键内容
|
74
|
+
// @en 3x4 Keyboard button content
|
75
|
+
|
76
|
+
var displayData = useMemo(function () {
|
77
|
+
var numberArr = randomOrder ? makeArrayRandom(contentArray) : contentArray;
|
78
|
+
var lastNum = numberArr.slice(-1)[0];
|
79
|
+
var finalData = splitArray(numberArr.slice(0, -1));
|
80
|
+
|
81
|
+
switch (type) {
|
82
|
+
case 'confirm':
|
83
|
+
finalData.push([lastNum, '.']);
|
84
|
+
break;
|
85
|
+
|
86
|
+
case 'tool':
|
87
|
+
finalData.push(['.', lastNum, {
|
88
|
+
type: 'delete'
|
89
|
+
}]);
|
90
|
+
break;
|
91
|
+
|
92
|
+
case 'number':
|
93
|
+
default:
|
94
|
+
finalData.push([{
|
95
|
+
type: 'keyboard'
|
96
|
+
}, lastNum, {
|
97
|
+
type: 'delete'
|
98
|
+
}]);
|
99
|
+
break;
|
100
|
+
}
|
101
|
+
|
102
|
+
return finalData;
|
103
|
+
}, [type]); // 右边一列
|
104
|
+
// @en Right column
|
105
|
+
|
106
|
+
var rightColumn = useMemo(function () {
|
107
|
+
switch (type) {
|
108
|
+
case 'number':
|
109
|
+
return [];
|
110
|
+
|
111
|
+
case 'confirm':
|
112
|
+
{
|
113
|
+
return [{
|
114
|
+
type: 'delete'
|
115
|
+
}];
|
116
|
+
}
|
117
|
+
|
118
|
+
case 'tool':
|
119
|
+
return ['+', '-', '×', '÷'];
|
120
|
+
|
121
|
+
default:
|
122
|
+
return [];
|
123
|
+
}
|
124
|
+
}, [type]); // 确认按钮需要在type为confirm时展示
|
125
|
+
// @en Display then confirm button when type is confirm
|
126
|
+
|
127
|
+
var getConfirmButton = useCallback(function () {
|
128
|
+
if (type !== 'confirm') {
|
129
|
+
return null;
|
130
|
+
}
|
131
|
+
|
132
|
+
return /*#__PURE__*/React.createElement("div", {
|
133
|
+
onClick: function onClick() {
|
134
|
+
confirmClosable && close();
|
135
|
+
onConfirm == null ? void 0 : onConfirm();
|
136
|
+
},
|
137
|
+
className: cls(prefix + "-key", prefix + "-key-confirm")
|
138
|
+
}, confirmButton || locale.Keyboard.confirm);
|
139
|
+
}, [type]); // 点击空白处关闭键盘
|
140
|
+
// @en Close keyboard when clicked the blank space
|
141
|
+
|
142
|
+
useEffect(function () {
|
143
|
+
var handlerDocumentClick = function handlerDocumentClick(e) {
|
144
|
+
if (!keyboardRef.current) {
|
145
|
+
return;
|
146
|
+
}
|
147
|
+
|
148
|
+
if (!keyboardRef.current.contains(e.target) && e.target !== keyboardRef.current) {
|
149
|
+
close();
|
150
|
+
}
|
151
|
+
};
|
152
|
+
|
153
|
+
document.addEventListener('click', handlerDocumentClick);
|
154
|
+
return function () {
|
155
|
+
document.removeEventListener('click', handlerDocumentClick);
|
156
|
+
};
|
157
|
+
}, []);
|
158
|
+
useImperativeHandle(ref, function () {
|
159
|
+
return _extends({
|
160
|
+
keyboard: keyboardRef.current
|
161
|
+
}, popupRef.current);
|
162
|
+
});
|
163
|
+
|
164
|
+
var handleButtonClick = function handleButtonClick(ele) {
|
165
|
+
switch (ele.type) {
|
166
|
+
case 'delete':
|
167
|
+
onDelete == null ? void 0 : onDelete();
|
168
|
+
break;
|
169
|
+
|
170
|
+
case 'keyboard':
|
171
|
+
close();
|
172
|
+
break;
|
173
|
+
|
174
|
+
default:
|
175
|
+
onChange == null ? void 0 : onChange(ele.value);
|
176
|
+
}
|
177
|
+
};
|
178
|
+
|
179
|
+
var renderButtonContent = function renderButtonContent(ele) {
|
180
|
+
switch (ele.type) {
|
181
|
+
case 'delete':
|
182
|
+
return deleteButton || /*#__PURE__*/React.createElement(IconKeyboardDelete, null);
|
183
|
+
|
184
|
+
case 'keyboard':
|
185
|
+
return keyboardButton || /*#__PURE__*/React.createElement(IconKeyboard, null);
|
186
|
+
|
187
|
+
default:
|
188
|
+
return ele.content;
|
189
|
+
}
|
190
|
+
};
|
191
|
+
|
192
|
+
var renderButton = function renderButton(data, key, extraClass) {
|
193
|
+
var ele = typeof data === 'string' || typeof data === 'number' ? {
|
194
|
+
type: 'content',
|
195
|
+
content: data,
|
196
|
+
value: data
|
197
|
+
} : data;
|
198
|
+
return /*#__PURE__*/React.createElement("button", {
|
199
|
+
onClick: function onClick() {
|
200
|
+
return handleButtonClick(ele);
|
201
|
+
},
|
202
|
+
className: cls(prefix + "-key", normalKeyClass, extraClass),
|
203
|
+
key: key,
|
204
|
+
style: normalKeyStyle
|
205
|
+
}, renderButtonContent(ele));
|
206
|
+
};
|
207
|
+
|
208
|
+
var renderKeyboardRightColumns = function renderKeyboardRightColumns() {
|
209
|
+
if (rightColumns) {
|
210
|
+
return rightColumns;
|
211
|
+
}
|
212
|
+
|
213
|
+
return rightColumn.length > 0 ? /*#__PURE__*/React.createElement("div", {
|
214
|
+
className: prefix + "-col"
|
215
|
+
}, rightColumn.map(function (item, index) {
|
216
|
+
return renderButton(item, String(index));
|
217
|
+
}), getConfirmButton()) : null;
|
218
|
+
};
|
219
|
+
|
220
|
+
return /*#__PURE__*/React.createElement(Popup, _extends({
|
221
|
+
ref: popupRef,
|
222
|
+
maskClass: prefix + "-popup",
|
223
|
+
close: close
|
224
|
+
}, resetProps), /*#__PURE__*/React.createElement("div", {
|
225
|
+
className: cls(prefix, "" + className),
|
226
|
+
style: style,
|
227
|
+
ref: keyboardRef
|
228
|
+
}, title, /*#__PURE__*/React.createElement("div", {
|
229
|
+
className: prefix + "-wrapper"
|
230
|
+
}, /*#__PURE__*/React.createElement("div", {
|
231
|
+
className: prefix + "-key-wrapper"
|
232
|
+
}, displayData.map(function (item, index) {
|
233
|
+
return /*#__PURE__*/React.createElement("div", {
|
234
|
+
className: prefix + "-row",
|
235
|
+
key: index
|
236
|
+
}, item.map(function (e, idx) {
|
237
|
+
var _renderButton;
|
238
|
+
|
239
|
+
return renderButton(e, String(idx), (_renderButton = {}, _renderButton[prefix + "-key-special"] = type === 'confirm' && index === displayData.length - 1 && idx === 0, _renderButton));
|
240
|
+
}));
|
241
|
+
})), renderKeyboardRightColumns())));
|
242
|
+
});
|
243
|
+
export default Keyboard;
|
@@ -0,0 +1,93 @@
|
|
1
|
+
.arco-keyboard {
|
2
|
+
background: #f2f3f5 ;
|
3
|
+
padding: 0.16rem ;
|
4
|
+
-webkit-touch-callout: none;
|
5
|
+
/* iOS Safari */
|
6
|
+
-webkit-user-select: none;
|
7
|
+
/* Chrome/Safari/Opera */
|
8
|
+
/* Konqueror */
|
9
|
+
/* Firefox */
|
10
|
+
/* Internet Explorer/Edge */
|
11
|
+
user-select: none;
|
12
|
+
/* Non-prefixed version, currently*/
|
13
|
+
}
|
14
|
+
.arco-keyboard-wrapper {
|
15
|
+
display: -webkit-box;
|
16
|
+
display: -webkit-flex;
|
17
|
+
display: flex;
|
18
|
+
}
|
19
|
+
.arco-keyboard-key-wrapper {
|
20
|
+
-webkit-box-flex: 2;
|
21
|
+
-webkit-flex: 2 0 auto;
|
22
|
+
flex: 2 0 auto;
|
23
|
+
}
|
24
|
+
.arco-keyboard-row {
|
25
|
+
display: -webkit-box;
|
26
|
+
display: -webkit-flex;
|
27
|
+
display: flex;
|
28
|
+
}
|
29
|
+
.arco-keyboard-row:not(.arco-keyboard-row:nth-last-child(1)) {
|
30
|
+
margin-bottom: 0.16rem ;
|
31
|
+
}
|
32
|
+
.arco-keyboard-row .arco-keyboard-key:not(.arco-keyboard-row .arco-keyboard-key:nth-child(1)) {
|
33
|
+
margin-left: 0.16rem ;
|
34
|
+
}
|
35
|
+
.arco-keyboard-row .arco-keyboard-key-special {
|
36
|
+
-webkit-box-flex: 2.1;
|
37
|
+
-webkit-flex: 2.1 0 auto;
|
38
|
+
flex: 2.1 0 auto;
|
39
|
+
}
|
40
|
+
.arco-keyboard-col {
|
41
|
+
-webkit-box-flex: 1;
|
42
|
+
-webkit-flex: 1;
|
43
|
+
flex: 1;
|
44
|
+
display: -webkit-box;
|
45
|
+
display: -webkit-flex;
|
46
|
+
display: flex;
|
47
|
+
-webkit-box-orient: vertical;
|
48
|
+
-webkit-box-direction: normal;
|
49
|
+
-webkit-flex-direction: column;
|
50
|
+
flex-direction: column;
|
51
|
+
margin-left: 0.16rem ;
|
52
|
+
}
|
53
|
+
.arco-keyboard-col .arco-keyboard-key:not(.arco-keyboard-col .arco-keyboard-key:nth-child(1)) {
|
54
|
+
margin-top: 0.16rem ;
|
55
|
+
}
|
56
|
+
.arco-keyboard-col .arco-keyboard-key-confirm {
|
57
|
+
-webkit-box-flex: 2.5;
|
58
|
+
-webkit-flex: 2.5 0 auto;
|
59
|
+
flex: 2.5 0 auto;
|
60
|
+
background: #165dff ;
|
61
|
+
color: #ffffff ;
|
62
|
+
font-size: 0.36rem ;
|
63
|
+
}
|
64
|
+
.arco-keyboard-key {
|
65
|
+
display: -webkit-box;
|
66
|
+
display: -webkit-flex;
|
67
|
+
display: flex;
|
68
|
+
-webkit-box-align: center;
|
69
|
+
-webkit-align-items: center;
|
70
|
+
align-items: center;
|
71
|
+
-webkit-box-pack: center;
|
72
|
+
-webkit-justify-content: center;
|
73
|
+
justify-content: center;
|
74
|
+
-webkit-box-flex: 1;
|
75
|
+
-webkit-flex: 1;
|
76
|
+
flex: 1;
|
77
|
+
font-weight: 500 ;
|
78
|
+
font-size: 0.44rem ;
|
79
|
+
line-height: 0.6rem ;
|
80
|
+
background: #ffffff ;
|
81
|
+
height: 0.96rem ;
|
82
|
+
border-radius: 0.08rem ;
|
83
|
+
color: #1d2129 ;
|
84
|
+
}
|
85
|
+
.arco-keyboard-key:active {
|
86
|
+
background: #e5e6eb ;
|
87
|
+
}
|
88
|
+
.arco-keyboard-key .arco-icon {
|
89
|
+
font-size: 0.52rem ;
|
90
|
+
}
|
91
|
+
.arco-keyboard-popup {
|
92
|
+
display: none;
|
93
|
+
}
|