@fjyueke/arco-mcp 1.0.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/README.md +85 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +244 -0
- package/metaData/components/action-sheet/doc.md +102 -0
- package/metaData/components/action-sheet/example/index.tsx +199 -0
- package/metaData/components/action-sheet/example/methods.tsx +6 -0
- package/metaData/components/avatar/doc.md +57 -0
- package/metaData/components/avatar/example/group.tsx +69 -0
- package/metaData/components/avatar/example/index.tsx +196 -0
- package/metaData/components/badge/doc.md +28 -0
- package/metaData/components/badge/example/index.tsx +128 -0
- package/metaData/components/button/doc.md +45 -0
- package/metaData/components/button/example/index.tsx +264 -0
- package/metaData/components/carousel/doc.md +89 -0
- package/metaData/components/carousel/example/index.tsx +1481 -0
- package/metaData/components/cell/doc.md +68 -0
- package/metaData/components/cell/example/arrow.tsx +13 -0
- package/metaData/components/cell/example/cell.tsx +71 -0
- package/metaData/components/cell/example/group.tsx +63 -0
- package/metaData/components/cell/example/index.tsx +19 -0
- package/metaData/components/checkbox/doc.md +91 -0
- package/metaData/components/checkbox/example/checkbox.tsx +158 -0
- package/metaData/components/checkbox/example/group.tsx +103 -0
- package/metaData/components/checkbox/example/index.tsx +25 -0
- package/metaData/components/circle-progress/doc.md +40 -0
- package/metaData/components/circle-progress/example/index.tsx +323 -0
- package/metaData/components/collapse/doc.md +74 -0
- package/metaData/components/collapse/example/collapse.tsx +183 -0
- package/metaData/components/collapse/example/group.tsx +136 -0
- package/metaData/components/collapse/example/index.tsx +16 -0
- package/metaData/components/collapse/example/utils.tsx +20 -0
- package/metaData/components/context-provider/doc.md +44 -0
- package/metaData/components/context-provider/example/index.tsx +208 -0
- package/metaData/components/count-down/doc.md +40 -0
- package/metaData/components/count-down/example/hooks.tsx +118 -0
- package/metaData/components/count-down/example/index.tsx +63 -0
- package/metaData/components/date-picker/doc.md +102 -0
- package/metaData/components/date-picker/example/index.tsx +545 -0
- package/metaData/components/dialog/doc.md +200 -0
- package/metaData/components/dialog/example/index.tsx +328 -0
- package/metaData/components/dialog/example/methods.tsx +56 -0
- package/metaData/components/divider/doc.md +25 -0
- package/metaData/components/divider/example/index.tsx +87 -0
- package/metaData/components/dropdown/doc.md +80 -0
- package/metaData/components/dropdown/example/dropdown.tsx +308 -0
- package/metaData/components/dropdown/example/index.tsx +19 -0
- package/metaData/components/dropdown/example/options.tsx +103 -0
- package/metaData/components/dropdown-menu/doc.md +91 -0
- package/metaData/components/dropdown-menu/example/dropdown-menu.tsx +270 -0
- package/metaData/components/dropdown-menu/example/index.tsx +16 -0
- package/metaData/components/ellipsis/doc.md +33 -0
- package/metaData/components/ellipsis/example/index.tsx +93 -0
- package/metaData/components/ellipsis/example/js-ellipsis.tsx +229 -0
- package/metaData/components/ellipsis/example/native-ellipsis.tsx +48 -0
- package/metaData/components/form/doc.md +90 -0
- package/metaData/components/form/example/form-item-context.tsx +8 -0
- package/metaData/components/form/example/form-item.tsx +378 -0
- package/metaData/components/form/example/index.tsx +87 -0
- package/metaData/components/form/example/linked-container.tsx +66 -0
- package/metaData/components/grid/doc.md +39 -0
- package/metaData/components/grid/example/index.tsx +252 -0
- package/metaData/components/icon/doc.md +15 -0
- package/metaData/components/icon/example/index.tsx +32 -0
- package/metaData/components/image/doc.md +62 -0
- package/metaData/components/image/example/index.tsx +528 -0
- package/metaData/components/image-picker/doc.md +116 -0
- package/metaData/components/image-picker/example/add-icon.tsx +14 -0
- package/metaData/components/image-picker/example/index.tsx +175 -0
- package/metaData/components/image-preview/doc.md +119 -0
- package/metaData/components/image-preview/example/index.tsx +1290 -0
- package/metaData/components/image-preview/example/methods.tsx +72 -0
- package/metaData/components/index-bar/doc.md +83 -0
- package/metaData/components/index-bar/example/group.tsx +93 -0
- package/metaData/components/index-bar/example/index.tsx +271 -0
- package/metaData/components/index-bar/example/side-bar.tsx +82 -0
- package/metaData/components/input/doc.md +60 -0
- package/metaData/components/input/example/hooks.tsx +259 -0
- package/metaData/components/input/example/index.tsx +134 -0
- package/metaData/components/input/example/props.tsx +183 -0
- package/metaData/components/keyboard/doc.md +73 -0
- package/metaData/components/keyboard/example/index.tsx +238 -0
- package/metaData/components/load-more/doc.md +48 -0
- package/metaData/components/load-more/example/index.tsx +395 -0
- package/metaData/components/loading/doc.md +34 -0
- package/metaData/components/loading/example/index.tsx +312 -0
- package/metaData/components/masking/doc.md +93 -0
- package/metaData/components/masking/example/index.tsx +410 -0
- package/metaData/components/masking/example/methods.tsx +88 -0
- package/metaData/components/nav-bar/doc.md +40 -0
- package/metaData/components/nav-bar/example/back-icon.tsx +28 -0
- package/metaData/components/nav-bar/example/index.tsx +305 -0
- package/metaData/components/notice-bar/doc.md +34 -0
- package/metaData/components/notice-bar/example/index.tsx +294 -0
- package/metaData/components/notify/doc.md +81 -0
- package/metaData/components/notify/example/index.tsx +171 -0
- package/metaData/components/notify/example/methods.tsx +83 -0
- package/metaData/components/pagination/doc.md +41 -0
- package/metaData/components/pagination/example/arrow.tsx +14 -0
- package/metaData/components/pagination/example/index.tsx +292 -0
- package/metaData/components/picker/doc.md +89 -0
- package/metaData/components/picker/example/index.tsx +217 -0
- package/metaData/components/picker-view/doc.md +57 -0
- package/metaData/components/picker-view/example/cascader.tsx +141 -0
- package/metaData/components/picker-view/example/index.tsx +297 -0
- package/metaData/components/picker-view/example/multi-picker.tsx +66 -0
- package/metaData/components/picker-view/example/picker-cell.tsx +416 -0
- package/metaData/components/popover/doc.md +144 -0
- package/metaData/components/popover/example/index.tsx +23 -0
- package/metaData/components/popover/example/menu.tsx +145 -0
- package/metaData/components/popover/example/popover-inner.tsx +147 -0
- package/metaData/components/popover/example/popover.tsx +268 -0
- package/metaData/components/popup/doc.md +101 -0
- package/metaData/components/popup/example/index.tsx +125 -0
- package/metaData/components/popup/example/methods.tsx +6 -0
- package/metaData/components/popup-swiper/doc.md +108 -0
- package/metaData/components/popup-swiper/example/index.tsx +332 -0
- package/metaData/components/popup-swiper/example/methods.tsx +6 -0
- package/metaData/components/portal/doc.md +14 -0
- package/metaData/components/portal/example/index.tsx +35 -0
- package/metaData/components/progress/doc.md +42 -0
- package/metaData/components/progress/example/index.tsx +256 -0
- package/metaData/components/pull-refresh/doc.md +37 -0
- package/metaData/components/pull-refresh/example/android-pull-refresh.tsx +260 -0
- package/metaData/components/pull-refresh/example/index.tsx +44 -0
- package/metaData/components/pull-refresh/example/ios-pull-refresh.tsx +216 -0
- package/metaData/components/radio/doc.md +89 -0
- package/metaData/components/radio/example/group.tsx +92 -0
- package/metaData/components/radio/example/index.tsx +25 -0
- package/metaData/components/radio/example/radio.tsx +22 -0
- package/metaData/components/rate/doc.md +33 -0
- package/metaData/components/rate/example/index.tsx +281 -0
- package/metaData/components/search-bar/doc.md +97 -0
- package/metaData/components/search-bar/example/association.tsx +89 -0
- package/metaData/components/search-bar/example/cancel-button.tsx +34 -0
- package/metaData/components/search-bar/example/highlight.tsx +66 -0
- package/metaData/components/search-bar/example/index.tsx +251 -0
- package/metaData/components/show-monitor/doc.md +34 -0
- package/metaData/components/show-monitor/example/index.tsx +646 -0
- package/metaData/components/skeleton/doc.md +101 -0
- package/metaData/components/skeleton/example/elements.tsx +290 -0
- package/metaData/components/skeleton/example/index.tsx +96 -0
- package/metaData/components/skeleton/example/skeleton-context.tsx +7 -0
- package/metaData/components/slider/doc.md +42 -0
- package/metaData/components/slider/example/index.tsx +326 -0
- package/metaData/components/slider/example/marks.tsx +50 -0
- package/metaData/components/slider/example/popover.tsx +38 -0
- package/metaData/components/slider/example/thumb.tsx +48 -0
- package/metaData/components/slider/example/useSliderIcon.tsx +38 -0
- package/metaData/components/slider/example/useSliderInit.tsx +170 -0
- package/metaData/components/stepper/doc.md +46 -0
- package/metaData/components/stepper/example/index.tsx +166 -0
- package/metaData/components/stepper/example/useButtonClick.tsx +74 -0
- package/metaData/components/stepper/example/useInputEvent.tsx +65 -0
- package/metaData/components/stepper/example/useValue.tsx +43 -0
- package/metaData/components/steps/doc.md +57 -0
- package/metaData/components/steps/example/index.tsx +123 -0
- package/metaData/components/steps/example/step.tsx +126 -0
- package/metaData/components/sticky/doc.md +45 -0
- package/metaData/components/sticky/example/index.tsx +430 -0
- package/metaData/components/swipe-action/doc.md +44 -0
- package/metaData/components/swipe-action/example/index.tsx +338 -0
- package/metaData/components/swipe-action/example/item.tsx +40 -0
- package/metaData/components/swipe-load/doc.md +43 -0
- package/metaData/components/swipe-load/example/index.tsx +339 -0
- package/metaData/components/swipe-load/example/type.tsx +153 -0
- package/metaData/components/switch/doc.md +38 -0
- package/metaData/components/switch/example/index.tsx +237 -0
- package/metaData/components/tab-bar/doc.md +57 -0
- package/metaData/components/tab-bar/example/index.tsx +18 -0
- package/metaData/components/tab-bar/example/item.tsx +74 -0
- package/metaData/components/tab-bar/example/tab-bar.tsx +105 -0
- package/metaData/components/tabs/doc.md +187 -0
- package/metaData/components/tabs/example/index.tsx +514 -0
- package/metaData/components/tabs/example/tab-cell-underline.tsx +320 -0
- package/metaData/components/tabs/example/tab-cell.tsx +433 -0
- package/metaData/components/tabs/example/tab-pane.tsx +349 -0
- package/metaData/components/tag/doc.md +80 -0
- package/metaData/components/tag/example/index.tsx +23 -0
- package/metaData/components/tag/example/list.tsx +97 -0
- package/metaData/components/tag/example/tag.tsx +85 -0
- package/metaData/components/textarea/doc.md +67 -0
- package/metaData/components/textarea/example/index.tsx +258 -0
- package/metaData/components/toast/doc.md +90 -0
- package/metaData/components/toast/example/index.tsx +335 -0
- package/metaData/components/toast/example/methods.tsx +87 -0
- package/metaData/components/transition/doc.md +19 -0
- package/metaData/components/transition/example/index.tsx +113 -0
- package/metaData/components/uploader/doc.md +82 -0
- package/metaData/components/uploader/example/index.tsx +208 -0
- package/metaData/components-index.json +242 -0
- package/package.json +56 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { appendElementById, removeElement } from '@arco-design/mobile-utils';
|
|
3
|
+
import { ReactDOMRender } from '../_helpers/render';
|
|
4
|
+
import { GlobalContextParams } from '../context-provider';
|
|
5
|
+
|
|
6
|
+
export interface OpenBaseProps {
|
|
7
|
+
onClose?: () => void;
|
|
8
|
+
close: (e) => void;
|
|
9
|
+
openIndex: number;
|
|
10
|
+
images: any[];
|
|
11
|
+
getContainer?: () => HTMLElement;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function open<P extends OpenBaseProps>(Component: React.FunctionComponent<P>) {
|
|
15
|
+
type Config = Omit<P, 'close'>;
|
|
16
|
+
return (config: Config, context?: GlobalContextParams) => {
|
|
17
|
+
const baseProps: Config & {
|
|
18
|
+
// 从config继承的属性
|
|
19
|
+
// @en Properties inherited from config
|
|
20
|
+
getContainer?: () => HTMLElement;
|
|
21
|
+
key?: string;
|
|
22
|
+
openIndex: P['openIndex'];
|
|
23
|
+
// 强制定义的属性
|
|
24
|
+
// @en Mandatory properties
|
|
25
|
+
onClose?: P['onClose'];
|
|
26
|
+
close: P['close'];
|
|
27
|
+
} = {
|
|
28
|
+
...(config || {}),
|
|
29
|
+
close: () => {},
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
// 不同的key用不同的容器挂载
|
|
33
|
+
// @en Different keys are mounted in different containers
|
|
34
|
+
const id = `_ARCO_IMAGE_PREVIEW_DIV_${baseProps.key || ''}_`;
|
|
35
|
+
const { child: div } = appendElementById(id, baseProps.getContainer);
|
|
36
|
+
let leaving = false;
|
|
37
|
+
const { render } = new ReactDOMRender(Component, div, context);
|
|
38
|
+
let dynamicProps = { ...baseProps, getContainer: () => div } as P;
|
|
39
|
+
|
|
40
|
+
function update(newConfig: Config) {
|
|
41
|
+
dynamicProps = {
|
|
42
|
+
...dynamicProps,
|
|
43
|
+
...(newConfig || {}),
|
|
44
|
+
};
|
|
45
|
+
render(dynamicProps);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function close() {
|
|
49
|
+
leaving = true;
|
|
50
|
+
dynamicProps.openIndex = -1;
|
|
51
|
+
render(dynamicProps);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
dynamicProps.close = close;
|
|
55
|
+
dynamicProps.onClose = () => {
|
|
56
|
+
baseProps.onClose && baseProps.onClose();
|
|
57
|
+
removeElement(div);
|
|
58
|
+
};
|
|
59
|
+
dynamicProps.openIndex = -1;
|
|
60
|
+
render(dynamicProps);
|
|
61
|
+
setTimeout(() => {
|
|
62
|
+
if (leaving) return;
|
|
63
|
+
dynamicProps.openIndex = baseProps.openIndex;
|
|
64
|
+
render(dynamicProps);
|
|
65
|
+
}, 20);
|
|
66
|
+
|
|
67
|
+
return {
|
|
68
|
+
close,
|
|
69
|
+
update,
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
### 导航
|
|
2
|
+
|
|
3
|
+
# 索引栏 IndexBar
|
|
4
|
+
|
|
5
|
+
索引栏组件
|
|
6
|
+
|
|
7
|
+
======
|
|
8
|
+
|
|
9
|
+
> 属性/Props
|
|
10
|
+
|
|
11
|
+
|参数|描述|类型|默认值|
|
|
12
|
+
|----------|-------------|------|------|
|
|
13
|
+
|className|自定义类名|string|-|
|
|
14
|
+
|style|自定义样式|CSSProperties|-|
|
|
15
|
+
|defaultIndex|默认要激活的索引|ReactText|-|
|
|
16
|
+
|disableSidebar|是否开启侧边栏功能|boolean|false|
|
|
17
|
+
|sticky|是否开启索引的自动吸顶效果|boolean|true|
|
|
18
|
+
|groups|索引栏内容|IndexBarGroupItem\<IndexBarBaseData\>\[\]|-|
|
|
19
|
+
|children|自定义内容的渲染,内容必须是IndexBar\.Group组件|ReactNode|-|
|
|
20
|
+
|tipType|侧边栏索引提示的样式类型 \- sweat 水滴形 \- toast 轻提示 \- none 关闭提示|"none" \| "sweat" \| "toast"|"toast"|
|
|
21
|
+
|scrollDuration|手动调用scrollToIndex时,滚动动画的执行时间|number|0|
|
|
22
|
+
|scrollBezier|手动调用scrollToIndex时,滚动的动画曲线|\[number, number, number, number\]|-|
|
|
23
|
+
|onChange|激活的索引改变时的回调,第一个参数是新的索引,第二个参数是改变方式:\- swipe 手动滑动页面触发变化 \- sidebar 侧边栏点击触发变化 \- manual 手动调用scrollToIndex触发|(index: ReactText, trigger: IndexBarChangeTrigger) =\> void|-|
|
|
24
|
+
|onGroupItemClick|IndexBar\.Group中某个子项被点击时的回调,使用JSX的写法时该回调不会生效,请在IndexBar\.Group上绑定对应属性|(index: ReactText, itemData: IndexBarBaseData, itemIndex: number) =\> void|-|
|
|
25
|
+
|renderSideBarItem|自定义侧边栏每个子项的内容渲染|(index: ReactText) =\> ReactNode|-|
|
|
26
|
+
|renderSideBar|自定义侧边栏渲染|(Content: ReactNode) =\> ReactElement\<any, string \| ((props: any) =\> ReactElement\<any, any\>) \| (new (props: any) =\> Component\<any, any, any\>)\>|-|
|
|
27
|
+
|renderTip|自定义使用侧边栏改变索引时,渲染提示的内容|(index: ReactText) =\> ReactNode|-|
|
|
28
|
+
|renderStickyItem|自定义IndexBar\.Group的索引标题内容渲染,使用JSX的写法时该回调不会生效,请在IndexBar\.Group上绑定对应属性|(index: ReactText) =\> ReactNode|-|
|
|
29
|
+
|renderGroupItem|自定义IndexBar\.Group的子项内容渲染,使用JSX的写法时该回调不会生效,请在IndexBar\.Group上绑定对应属性|(index: ReactText, itemData: IndexBarBaseData, itemIndex: number) =\> ReactNode|-|
|
|
30
|
+
|
|
31
|
+
> 引用/Refs
|
|
32
|
+
|
|
33
|
+
|参数|描述|类型|
|
|
34
|
+
|----------|-------------|------|
|
|
35
|
+
|dom|最外层 DOM 元素|HTMLDivElement|
|
|
36
|
+
|scrollToIndex|手动滚动到指定的索引位置|(index?: ReactText, rightNow?: boolean) =\> void|
|
|
37
|
+
|recalculatePosition|局部滚动模式下,如果容器外部还有嵌套滚动,可主动调用此方法,让 sticky 的元素主动更新 fixed 位置|(index?: ReactText) =\> void|
|
|
38
|
+
|
|
39
|
+
> IndexBar.Group
|
|
40
|
+
|
|
41
|
+
|参数|描述|类型|默认值|
|
|
42
|
+
|----------|-------------|------|------|
|
|
43
|
+
|className|自定义类名|string|-|
|
|
44
|
+
|style|自定义样式|CSSProperties|-|
|
|
45
|
+
|children|自定义内容的渲染,有自定义内容优先渲染自定义内容,否则渲染list传递的数据|ReactNode|-|
|
|
46
|
+
|listKey|自定义提取List的key作为列表渲染的key,默认选取listItem的所在数组位置|(data: IndexBarBaseData, listItemIndex: number) =\> ReactText|-|
|
|
47
|
+
|onGroupItemClick|IndexBar\.Group中某个子项被点击时的回调|(index: ReactText, itemData: IndexBarBaseData, itemIndex: number) =\> void|-|
|
|
48
|
+
|renderStickyItem|自定义IndexBar\.Group的索引标题内容渲染|(index: ReactText) =\> ReactNode|-|
|
|
49
|
+
|renderGroupItem|自定义IndexBar\.Group的子项内容渲染|(index: ReactText, itemData: IndexBarBaseData, itemIndex: number) =\> ReactNode|-|
|
|
50
|
+
|index|IndexBarGroup对应的索引|ReactText|必填|
|
|
51
|
+
|list|IndexBarGroup中要渲染的列表数据,如果已经传递了children这个属性,则list这个属性不会生效|IndexBarBaseData\[\]|-|
|
|
52
|
+
|
|
53
|
+
> IndexBarGroupItem
|
|
54
|
+
|
|
55
|
+
|参数|描述|类型|
|
|
56
|
+
|----------|-------------|------|
|
|
57
|
+
|Data|-|any|
|
|
58
|
+
|index|IndexBarGroup对应的索引|ReactText|
|
|
59
|
+
|list|IndexBarGroup中要渲染的列表数据,如果已经传递了children这个属性,则list这个属性不会生效|IndexBarBaseData\[\]|
|
|
60
|
+
|
|
61
|
+
> IndexBarBaseData
|
|
62
|
+
|
|
63
|
+
|参数|描述|类型|
|
|
64
|
+
|----------|-------------|------|
|
|
65
|
+
|content|内容|ReactNode|
|
|
66
|
+
|
|
67
|
+
> IndexBarTipType
|
|
68
|
+
|
|
69
|
+
```
|
|
70
|
+
"none" | "sweat" | "toast"
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
> IndexBarChangeTrigger
|
|
74
|
+
|
|
75
|
+
```
|
|
76
|
+
"swipe" | "manual" | "sidebar"
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
> IndexBarGroupRef
|
|
80
|
+
|
|
81
|
+
|参数|描述|类型|
|
|
82
|
+
|----------|-------------|------|
|
|
83
|
+
|dom|组件外层dom元素|HTMLDivElement|
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { cls } from '@arco-design/mobile-utils';
|
|
2
|
+
import React, { forwardRef, Ref, useContext, useImperativeHandle, useRef } from 'react';
|
|
3
|
+
import { GlobalContext } from '../context-provider';
|
|
4
|
+
import Sticky from '../sticky';
|
|
5
|
+
import { IndexBarContext } from './context';
|
|
6
|
+
import { IndexBarBaseData, IndexBarGroupProps, IndexBarGroupRef } from './type';
|
|
7
|
+
|
|
8
|
+
export const IndexBarGroup = forwardRef(
|
|
9
|
+
<Data extends IndexBarBaseData = IndexBarBaseData>(
|
|
10
|
+
props: IndexBarGroupProps<Data>,
|
|
11
|
+
ref: Ref<IndexBarGroupRef>,
|
|
12
|
+
) => {
|
|
13
|
+
const {
|
|
14
|
+
index: groupIndex,
|
|
15
|
+
list,
|
|
16
|
+
className,
|
|
17
|
+
style,
|
|
18
|
+
children,
|
|
19
|
+
listKey,
|
|
20
|
+
onGroupItemClick,
|
|
21
|
+
renderGroupItem,
|
|
22
|
+
renderStickyItem,
|
|
23
|
+
} = props;
|
|
24
|
+
const { prefixCls } = useContext(GlobalContext);
|
|
25
|
+
// 有可能是IndexBar.Group的写法,因此sticky从context中获得
|
|
26
|
+
const { sticky, getScrollContainer, activeIndex, updateRef } = useContext(IndexBarContext);
|
|
27
|
+
const domRef = useRef<HTMLDivElement | null>(null);
|
|
28
|
+
|
|
29
|
+
useImperativeHandle(ref, () => ({
|
|
30
|
+
dom: domRef.current,
|
|
31
|
+
}));
|
|
32
|
+
|
|
33
|
+
// 用户自定义列表元素vnode的key
|
|
34
|
+
const formatGetListKey = (data: Data, index: number) => listKey?.(data, index) ?? index;
|
|
35
|
+
|
|
36
|
+
const renderChildren = () =>
|
|
37
|
+
children ??
|
|
38
|
+
list?.map((data, index) => (
|
|
39
|
+
<div
|
|
40
|
+
className={`${prefixCls}-index-bar-group-item`}
|
|
41
|
+
key={formatGetListKey(data, index)}
|
|
42
|
+
onClick={() => onGroupItemClick?.(groupIndex, data, index)}
|
|
43
|
+
>
|
|
44
|
+
{renderGroupItem ? renderGroupItem(groupIndex, data, index) : data.content}
|
|
45
|
+
</div>
|
|
46
|
+
)) ??
|
|
47
|
+
null;
|
|
48
|
+
|
|
49
|
+
const renderIndexTitle = () => {
|
|
50
|
+
if (renderStickyItem) {
|
|
51
|
+
return renderStickyItem(groupIndex);
|
|
52
|
+
}
|
|
53
|
+
const titleDom = (
|
|
54
|
+
<div
|
|
55
|
+
className={cls(`${prefixCls}-index-bar-group-title`, {
|
|
56
|
+
[`${prefixCls}-index-bar-group-active`]: activeIndex === groupIndex,
|
|
57
|
+
})}
|
|
58
|
+
>
|
|
59
|
+
{groupIndex}
|
|
60
|
+
</div>
|
|
61
|
+
);
|
|
62
|
+
const groupDom = domRef.current;
|
|
63
|
+
return sticky ? (
|
|
64
|
+
<Sticky
|
|
65
|
+
getContainer={() => groupDom as HTMLDivElement}
|
|
66
|
+
stickyStyle="absolute"
|
|
67
|
+
getScrollContainer={getScrollContainer as () => HTMLDivElement}
|
|
68
|
+
ref={stickyRef => {
|
|
69
|
+
if (stickyRef) {
|
|
70
|
+
updateRef(groupIndex, stickyRef);
|
|
71
|
+
}
|
|
72
|
+
}}
|
|
73
|
+
>
|
|
74
|
+
{titleDom}
|
|
75
|
+
</Sticky>
|
|
76
|
+
) : (
|
|
77
|
+
titleDom
|
|
78
|
+
);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
return (
|
|
82
|
+
<div
|
|
83
|
+
className={cls(`${prefixCls}-index-bar-group`, className)}
|
|
84
|
+
style={style}
|
|
85
|
+
data-index={groupIndex}
|
|
86
|
+
ref={domRef}
|
|
87
|
+
>
|
|
88
|
+
{renderIndexTitle()}
|
|
89
|
+
{renderChildren()}
|
|
90
|
+
</div>
|
|
91
|
+
);
|
|
92
|
+
},
|
|
93
|
+
);
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
import { cls, componentWrapper, scrollWithAnimation } from '@arco-design/mobile-utils';
|
|
2
|
+
import lodashThrottle from 'lodash.throttle';
|
|
3
|
+
import React, {
|
|
4
|
+
useRef,
|
|
5
|
+
forwardRef,
|
|
6
|
+
Ref,
|
|
7
|
+
useImperativeHandle,
|
|
8
|
+
useMemo,
|
|
9
|
+
useState,
|
|
10
|
+
useEffect,
|
|
11
|
+
} from 'react';
|
|
12
|
+
import { ContextLayout } from '../context-provider';
|
|
13
|
+
import { IndexBarContext } from './context';
|
|
14
|
+
import { IndexBarGroup as Group } from './group';
|
|
15
|
+
import { IndexBarSideBar } from './side-bar';
|
|
16
|
+
import type {
|
|
17
|
+
IndexBarBaseData,
|
|
18
|
+
IndexBarChangeTrigger,
|
|
19
|
+
IndexBarIndexType,
|
|
20
|
+
IndexBarProps,
|
|
21
|
+
IndexBarRef,
|
|
22
|
+
IndexBarContext as IndexBarContentType,
|
|
23
|
+
IndexBarScrollParams,
|
|
24
|
+
IndexBarGroupProps,
|
|
25
|
+
} from './type';
|
|
26
|
+
import {
|
|
27
|
+
filterValidIndexBarChild,
|
|
28
|
+
getGroupDomFromIndex,
|
|
29
|
+
getFormatIndex,
|
|
30
|
+
isValidIndex,
|
|
31
|
+
} from './utils';
|
|
32
|
+
import { StickyRef } from '../sticky';
|
|
33
|
+
|
|
34
|
+
export type {
|
|
35
|
+
IndexBarProps,
|
|
36
|
+
IndexBarRef,
|
|
37
|
+
IndexBarGroupProps,
|
|
38
|
+
IndexBarGroupRef,
|
|
39
|
+
IndexBarChangeTrigger,
|
|
40
|
+
IndexBarIndexType,
|
|
41
|
+
IndexBarTipType,
|
|
42
|
+
} from './type';
|
|
43
|
+
|
|
44
|
+
const IndexBar = forwardRef(
|
|
45
|
+
<Data extends IndexBarBaseData = IndexBarBaseData>(
|
|
46
|
+
props: IndexBarProps<Data>,
|
|
47
|
+
ref: Ref<IndexBarRef>,
|
|
48
|
+
) => {
|
|
49
|
+
const {
|
|
50
|
+
className = '',
|
|
51
|
+
style,
|
|
52
|
+
children,
|
|
53
|
+
sticky = true,
|
|
54
|
+
groups = [],
|
|
55
|
+
tipType = 'toast',
|
|
56
|
+
defaultIndex,
|
|
57
|
+
scrollBezier,
|
|
58
|
+
scrollDuration = 0,
|
|
59
|
+
disableSidebar = false,
|
|
60
|
+
onChange,
|
|
61
|
+
onGroupItemClick,
|
|
62
|
+
renderSideBar,
|
|
63
|
+
renderSideBarItem,
|
|
64
|
+
renderTip,
|
|
65
|
+
renderStickyItem,
|
|
66
|
+
renderGroupItem,
|
|
67
|
+
} = props;
|
|
68
|
+
// 最外层dom元素的ref
|
|
69
|
+
const domRef = useRef<HTMLDivElement | null>(null);
|
|
70
|
+
// 所有group的容器dom,domRef的内容就是contanerRef和sidebar的内容
|
|
71
|
+
const containerRef = useRef<HTMLDivElement | null>(null);
|
|
72
|
+
// 过滤掉jsx写法中,奇怪的child
|
|
73
|
+
const formatChildren = filterValidIndexBarChild(children);
|
|
74
|
+
// 所有的索引内容,优先从props.groups中获取,再从formatChildren中获取
|
|
75
|
+
const indexes = useMemo(() => {
|
|
76
|
+
if (groups.length) {
|
|
77
|
+
return groups.map(group => group.index);
|
|
78
|
+
}
|
|
79
|
+
return formatChildren.map(child => (child.props as IndexBarGroupProps).index);
|
|
80
|
+
}, [children, groups]);
|
|
81
|
+
const groupRefs = useRef<Record<IndexBarIndexType, StickyRef>>({});
|
|
82
|
+
// 当前激活的Index
|
|
83
|
+
const [activeIndex, setActiveIndex] = useState<IndexBarIndexType | undefined>(
|
|
84
|
+
() => defaultIndex ?? indexes?.[0],
|
|
85
|
+
);
|
|
86
|
+
// 给IndexBarGroup用的上下文,主要是为了兼容jsx的写法
|
|
87
|
+
const contextValue = useMemo<IndexBarContentType>(
|
|
88
|
+
() => ({
|
|
89
|
+
sticky,
|
|
90
|
+
getScrollContainer: () => containerRef.current as HTMLDivElement,
|
|
91
|
+
activeIndex,
|
|
92
|
+
updateRef: (groupIndex, stickyRef) => {
|
|
93
|
+
groupRefs.current[groupIndex] = stickyRef;
|
|
94
|
+
},
|
|
95
|
+
}),
|
|
96
|
+
[sticky, activeIndex],
|
|
97
|
+
);
|
|
98
|
+
// 用户是否正在触碰sidebar, 如果为true的话,禁用handleScroll的处理
|
|
99
|
+
const isScrollHandlerDisabledRef = useRef(false);
|
|
100
|
+
|
|
101
|
+
const handleChangeActiveIndex = (
|
|
102
|
+
index: IndexBarIndexType,
|
|
103
|
+
type: IndexBarChangeTrigger,
|
|
104
|
+
): void => {
|
|
105
|
+
setActiveIndex(oldActiveIndex => {
|
|
106
|
+
const newActiveIndex = getFormatIndex(index, oldActiveIndex);
|
|
107
|
+
// 和上一次激活的acitveIndex不同,再触发onChange事件
|
|
108
|
+
if (newActiveIndex !== oldActiveIndex) {
|
|
109
|
+
onChange?.(newActiveIndex, type);
|
|
110
|
+
}
|
|
111
|
+
return newActiveIndex;
|
|
112
|
+
});
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
// 要滚动到哪个指定的index
|
|
116
|
+
const handleScrollIntoIndex = (params: IndexBarScrollParams) => {
|
|
117
|
+
const { index, type, rightNow = false } = params;
|
|
118
|
+
// 不传index默认走第一个index
|
|
119
|
+
const formatIndex = index ?? indexes?.[0];
|
|
120
|
+
const containerDom = containerRef.current;
|
|
121
|
+
if (!isValidIndex(index) || !containerDom) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
// 寻找Index对应的groupDom
|
|
125
|
+
const groupDom = getGroupDomFromIndex(containerDom, formatIndex);
|
|
126
|
+
if (groupDom) {
|
|
127
|
+
handleChangeActiveIndex(formatIndex, type);
|
|
128
|
+
const duration = rightNow ? 0 : scrollDuration;
|
|
129
|
+
const targetScrollTop = groupDom.offsetTop;
|
|
130
|
+
// 将屏幕滚动到groupDom
|
|
131
|
+
// 手动触发需要禁用handleScroll事件
|
|
132
|
+
if (type === 'manual') {
|
|
133
|
+
isScrollHandlerDisabledRef.current = true;
|
|
134
|
+
setTimeout(() => {
|
|
135
|
+
isScrollHandlerDisabledRef.current = false;
|
|
136
|
+
}, duration);
|
|
137
|
+
}
|
|
138
|
+
if (duration > 0) {
|
|
139
|
+
scrollWithAnimation(
|
|
140
|
+
containerDom.scrollTop,
|
|
141
|
+
targetScrollTop,
|
|
142
|
+
top => (containerDom.scrollTop = top),
|
|
143
|
+
duration,
|
|
144
|
+
scrollBezier,
|
|
145
|
+
);
|
|
146
|
+
} else {
|
|
147
|
+
containerDom.scrollTop = targetScrollTop;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
useImperativeHandle(ref, () => ({
|
|
153
|
+
dom: domRef.current,
|
|
154
|
+
scrollToIndex(index, rightNow) {
|
|
155
|
+
if (isValidIndex(index)) {
|
|
156
|
+
handleScrollIntoIndex({
|
|
157
|
+
index,
|
|
158
|
+
rightNow,
|
|
159
|
+
type: 'manual',
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
recalculatePosition(targetIndex) {
|
|
164
|
+
const formatIndex = targetIndex ?? activeIndex;
|
|
165
|
+
if (formatIndex) {
|
|
166
|
+
const targetStickyRef = groupRefs.current[formatIndex];
|
|
167
|
+
if (targetStickyRef && targetStickyRef.recalculatePosition) {
|
|
168
|
+
targetStickyRef.recalculatePosition();
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
}));
|
|
173
|
+
|
|
174
|
+
const renderChildren = () => {
|
|
175
|
+
if (formatChildren.length) {
|
|
176
|
+
return formatChildren;
|
|
177
|
+
}
|
|
178
|
+
return groups?.map(group => (
|
|
179
|
+
<Group
|
|
180
|
+
index={group.index}
|
|
181
|
+
key={group.index}
|
|
182
|
+
list={group.list}
|
|
183
|
+
onGroupItemClick={onGroupItemClick}
|
|
184
|
+
renderGroupItem={renderGroupItem}
|
|
185
|
+
renderStickyItem={renderStickyItem}
|
|
186
|
+
/>
|
|
187
|
+
));
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
useEffect(() => {
|
|
191
|
+
const handleScroll = lodashThrottle(() => {
|
|
192
|
+
// 用户正在触碰sidebar和手动触发scroll时禁用滚动事件的处理
|
|
193
|
+
if (!containerRef.current || isScrollHandlerDisabledRef.current) {
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// 根据滚动的距离,获取处于屏幕最顶部的group是哪个
|
|
198
|
+
const scrollTop = containerRef.current.scrollTop;
|
|
199
|
+
for (let i = 0; i < containerRef.current.children.length; i++) {
|
|
200
|
+
const child = containerRef.current.children[i] as HTMLDivElement;
|
|
201
|
+
if (!child || !child.dataset || typeof child.dataset.index === 'undefined') {
|
|
202
|
+
continue;
|
|
203
|
+
}
|
|
204
|
+
if (child.offsetTop + child.clientHeight >= scrollTop) {
|
|
205
|
+
handleChangeActiveIndex(child.dataset.index, 'swipe');
|
|
206
|
+
break;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}, 100);
|
|
210
|
+
|
|
211
|
+
// 页面挂载时,如果是传入了defaultIndex,则滚动到对应位置
|
|
212
|
+
if (activeIndex) {
|
|
213
|
+
handleScrollIntoIndex({
|
|
214
|
+
index: activeIndex,
|
|
215
|
+
rightNow: true,
|
|
216
|
+
type: 'manual',
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
containerRef.current?.addEventListener('scroll', handleScroll);
|
|
220
|
+
|
|
221
|
+
return () => {
|
|
222
|
+
containerRef.current?.removeEventListener('scroll', handleScroll);
|
|
223
|
+
};
|
|
224
|
+
}, []);
|
|
225
|
+
|
|
226
|
+
return (
|
|
227
|
+
<ContextLayout>
|
|
228
|
+
{({ prefixCls }) => (
|
|
229
|
+
<IndexBarContext.Provider value={contextValue}>
|
|
230
|
+
<div
|
|
231
|
+
className={cls(`${prefixCls}-index-bar`, className)}
|
|
232
|
+
style={style}
|
|
233
|
+
ref={domRef}
|
|
234
|
+
>
|
|
235
|
+
<div className={`${prefixCls}-index-bar-container`} ref={containerRef}>
|
|
236
|
+
{renderChildren()}
|
|
237
|
+
</div>
|
|
238
|
+
{!disableSidebar && (
|
|
239
|
+
<IndexBarSideBar
|
|
240
|
+
tipType={tipType}
|
|
241
|
+
activeIndex={activeIndex}
|
|
242
|
+
prefixCls={prefixCls}
|
|
243
|
+
indexes={indexes}
|
|
244
|
+
onTouching={isTouching =>
|
|
245
|
+
(isScrollHandlerDisabledRef.current = isTouching)
|
|
246
|
+
}
|
|
247
|
+
onClick={newIndex =>
|
|
248
|
+
handleScrollIntoIndex({ index: newIndex, type: 'sidebar' })
|
|
249
|
+
}
|
|
250
|
+
renderSideBar={renderSideBar}
|
|
251
|
+
renderSideBarItem={renderSideBarItem}
|
|
252
|
+
renderTip={renderTip}
|
|
253
|
+
/>
|
|
254
|
+
)}
|
|
255
|
+
</div>
|
|
256
|
+
</IndexBarContext.Provider>
|
|
257
|
+
)}
|
|
258
|
+
</ContextLayout>
|
|
259
|
+
);
|
|
260
|
+
},
|
|
261
|
+
);
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* 索引栏组件
|
|
265
|
+
* @en IndexBar component
|
|
266
|
+
* @type 导航
|
|
267
|
+
* @type_en Navigation
|
|
268
|
+
* @name 索引栏
|
|
269
|
+
* @name_en SearchBar
|
|
270
|
+
*/
|
|
271
|
+
export default componentWrapper(IndexBar, { Group });
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import React, { ReactNode, useState } from 'react';
|
|
2
|
+
import { cls } from '@arco-design/mobile-utils';
|
|
3
|
+
import { IndexBarIndexType, IndexBarSideBarProps, IndexBarTipType } from './type';
|
|
4
|
+
|
|
5
|
+
export function IndexBarSideBar(props: IndexBarSideBarProps) {
|
|
6
|
+
const {
|
|
7
|
+
indexes,
|
|
8
|
+
prefixCls,
|
|
9
|
+
onTouching,
|
|
10
|
+
onClick,
|
|
11
|
+
activeIndex,
|
|
12
|
+
tipType,
|
|
13
|
+
renderSideBar,
|
|
14
|
+
renderSideBarItem = index => index,
|
|
15
|
+
renderTip: propsRenderTip,
|
|
16
|
+
} = props;
|
|
17
|
+
const [isTouching, originSetIsTouching] = useState(false);
|
|
18
|
+
|
|
19
|
+
const setIsTouching = (touching: boolean) => {
|
|
20
|
+
originSetIsTouching(touching);
|
|
21
|
+
onTouching(touching);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const handleTouchingStart = () => setIsTouching(true);
|
|
25
|
+
|
|
26
|
+
const handleTouchingStop = () => setIsTouching(false);
|
|
27
|
+
|
|
28
|
+
const handleTouchMove = (e: React.TouchEvent<HTMLDivElement>) => {
|
|
29
|
+
if (!isTouching || !e.touches?.length) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const { clientX, clientY } = e.touches[0];
|
|
33
|
+
const target = document.elementFromPoint(clientX, clientY) as HTMLElement;
|
|
34
|
+
if (target && target.dataset?.index) {
|
|
35
|
+
onClick(target.dataset.index);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const renderSideBarTip = (index: IndexBarIndexType, type: IndexBarTipType): ReactNode => {
|
|
40
|
+
if (propsRenderTip) {
|
|
41
|
+
return propsRenderTip(index);
|
|
42
|
+
}
|
|
43
|
+
return <div className={`${prefixCls}-index-bar-sidebar-${type}`}>{index}</div>;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const node = (
|
|
47
|
+
<div
|
|
48
|
+
className={cls(`${prefixCls}-index-bar-sidebar`, {
|
|
49
|
+
[`${prefixCls}-index-bar-sidebar-touching`]: isTouching,
|
|
50
|
+
})}
|
|
51
|
+
onTouchStart={() => handleTouchingStart()}
|
|
52
|
+
onTouchEnd={() => handleTouchingStop()}
|
|
53
|
+
onTouchCancel={() => handleTouchingStop()}
|
|
54
|
+
onTouchMove={handleTouchMove}
|
|
55
|
+
>
|
|
56
|
+
{tipType === 'toast' &&
|
|
57
|
+
isTouching &&
|
|
58
|
+
activeIndex &&
|
|
59
|
+
renderSideBarTip(activeIndex, 'toast')}
|
|
60
|
+
{indexes.map(index => (
|
|
61
|
+
<div
|
|
62
|
+
className={cls(`${prefixCls}-index-bar-sidebar-item`, {
|
|
63
|
+
[`${prefixCls}-index-bar-sidebar-active`]: activeIndex === index,
|
|
64
|
+
})}
|
|
65
|
+
key={index}
|
|
66
|
+
onTouchStart={() => onClick(index)}
|
|
67
|
+
data-index={index}
|
|
68
|
+
>
|
|
69
|
+
{tipType === 'sweat' &&
|
|
70
|
+
isTouching &&
|
|
71
|
+
activeIndex === index &&
|
|
72
|
+
renderSideBarTip(index, 'sweat')}
|
|
73
|
+
<div className={`${prefixCls}-index-bar-sidebar-item-wrapper`}>
|
|
74
|
+
{renderSideBarItem(index)}
|
|
75
|
+
</div>
|
|
76
|
+
</div>
|
|
77
|
+
))}
|
|
78
|
+
</div>
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
return renderSideBar ? renderSideBar(node) : node;
|
|
82
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
### 数据录入
|
|
2
|
+
|
|
3
|
+
# 输入框 Input
|
|
4
|
+
|
|
5
|
+
输入框组件,支持添加前后缀。
|
|
6
|
+
|
|
7
|
+
======
|
|
8
|
+
|
|
9
|
+
> 属性/Props
|
|
10
|
+
|
|
11
|
+
|参数|描述|类型|默认值|
|
|
12
|
+
|----------|-------------|------|------|
|
|
13
|
+
|type|输入框类型|string|"text"|
|
|
14
|
+
|pattern|检查控件值的正则表达式|string|-|
|
|
15
|
+
|inputClass|输入框dom自定义类名|string|-|
|
|
16
|
+
|inputStyle|输入框dom自定义样式|CSSProperties|-|
|
|
17
|
+
|nativeProps|其他未列出的原生属性,优先级低于已列出的组件属性|InputHTMLAttributes\<HTMLInputElement\>|-|
|
|
18
|
+
|ariaLabel|无障碍label|string|-|
|
|
19
|
+
|id|输入框的id|string|-|
|
|
20
|
+
|name|输入框的name|string|-|
|
|
21
|
+
|className|自定义类名|string|-|
|
|
22
|
+
|style|自定义样式|CSSProperties|-|
|
|
23
|
+
|value|绑定值,传入即受控|string|-|
|
|
24
|
+
|defaultValue|默认值|string|-|
|
|
25
|
+
|maxLength|最大输入长度|number|-|
|
|
26
|
+
|border|边框展示类型|"all" \| "half" \| "bottom" \| "none"|"half"|
|
|
27
|
+
|placeholder|占位文本|string|-|
|
|
28
|
+
|disabled|输入框是否禁用|boolean|-|
|
|
29
|
+
|readOnly|是否只读|boolean|-|
|
|
30
|
+
|autoFocus|是否自动获取焦点,开启后会触发一次onClick事件|boolean|-|
|
|
31
|
+
|blockChangeWhenCompositing|当 ios 输入中文时,输拼音的过程不触发onChange,仅确认选择后触发|boolean|false|
|
|
32
|
+
|label|输入框左侧文本|ReactNode|-|
|
|
33
|
+
|required|是否必填项|boolean|-|
|
|
34
|
+
|validator|正则验证,不符合验证的不允许输入|RegExp \| ((value: string) =\> boolean)|-|
|
|
35
|
+
|prepend|输入框头部内容,在输入框外部|ReactNode \| ((focusing: boolean, inputValue: string) =\> ReactNode)|-|
|
|
36
|
+
|append|输入框尾部内容,在输入框外部|ReactNode \| ((focusing: boolean, inputValue: string) =\> ReactNode)|-|
|
|
37
|
+
|blurBeforeFocus|在聚焦之前blur掉,即切换不同input时会重新弹起键盘,常用于input type切换时重新加载键盘,安卓上有效|boolean|-|
|
|
38
|
+
|clearable|是否有清除按钮|boolean|-|
|
|
39
|
+
|clearShowType|清除按钮展示时机:focus \- 聚焦时展示 value \- 有值则展示 always \- 始终展示|"focus" \| "value" \| "always"|"focus"|
|
|
40
|
+
|preventEventWhenClearing|在聚焦模式下点击清除按钮时,是否要屏蔽对应产生的onBlur和onFocus事件|boolean|true|
|
|
41
|
+
|clearIcon|清除按钮类型,也可自定义|ReactNode|\<IconClear className="clear-icon" /\>|
|
|
42
|
+
|onClear|按下清除按钮回调|(e: TouchEvent\<HTMLElement\>) =\> void|-|
|
|
43
|
+
|prefix|输入框前置内容,在输入框内部,也可自定义|ReactNode|-|
|
|
44
|
+
|suffix|输入框后置内容,在输入框内部,也可自定义|ReactNode|-|
|
|
45
|
+
|onChange|数据改变时触发(失去焦点时)|(e: ChangeEvent\<HTMLInputElement\>, value: string) =\> void|-|
|
|
46
|
+
|onInput|数据改变时触发|(e: ChangeEvent\<HTMLInputElement\>, value: string) =\> void|-|
|
|
47
|
+
|onFocus|输入框聚焦时触发|(e: FocusEvent\<HTMLInputElement, Element\>) =\> void|-|
|
|
48
|
+
|onBlur|输入框失去焦点时触发|(e: FocusEvent\<HTMLInputElement, Element\>) =\> void|-|
|
|
49
|
+
|onClick|点击输入框事件|(e: MouseEvent\<HTMLInputElement, MouseEvent\>) =\> void|-|
|
|
50
|
+
|onKeyUp|原生的keyup事件|(e: KeyboardEvent\<HTMLInputElement\>) =\> void|-|
|
|
51
|
+
|onKeyDown|原生的keydown事件|(e: KeyboardEvent\<HTMLInputElement\>) =\> void|-|
|
|
52
|
+
|onKeyPress|原生的keypress事件|(e: KeyboardEvent\<HTMLInputElement\>) =\> void|-|
|
|
53
|
+
|onPressEnter|按下回车键时触发|(e: KeyboardEvent\<HTMLInputElement\>) =\> void|-|
|
|
54
|
+
|
|
55
|
+
> 引用/Refs
|
|
56
|
+
|
|
57
|
+
|参数|描述|类型|
|
|
58
|
+
|----------|-------------|------|
|
|
59
|
+
|dom|最外层元素 DOM|HTMLDivElement|
|
|
60
|
+
|input|原生输入框 DOM|HTMLInputElement|
|