@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,200 @@
|
|
|
1
|
+
### 反馈
|
|
2
|
+
|
|
3
|
+
# 对话框 Dialog
|
|
4
|
+
|
|
5
|
+
模态对话框,在浮层中显示,引导用户进行相关操作。默认做了防滚动穿透处理,如果弹层内容中需要滚动,则需将滚动容器传入`getScrollContainer`属性以在未滚动到顶部或底部时释放滚动。
|
|
6
|
+
|
|
7
|
+
======
|
|
8
|
+
|
|
9
|
+
> 属性/Props
|
|
10
|
+
|
|
11
|
+
|参数|描述|类型|默认值|
|
|
12
|
+
|----------|-------------|------|------|
|
|
13
|
+
|title|弹窗标题|ReactNode|-|
|
|
14
|
+
|footer|底部按钮配置|FooterButtonOptions\[\]|[]|
|
|
15
|
+
|footerType|底部按钮样式,grid表示通栏样式,button表示按钮样式,platform=ios时有效|"grid" \| "button"|"grid"|
|
|
16
|
+
|renderFooter|自定义渲染footer|() =\> ReactNode|-|
|
|
17
|
+
|footerCollapseCount|底部按钮大于等于多少个时竖向排布|number|3|
|
|
18
|
+
|titleAlign|标题对齐方向|"left" \| "center" \| "right"|platform=android 时为"left",否则为"center"|
|
|
19
|
+
|contentAlign|内容对齐方向|"left" \| "center" \| "right"|platform=android 时为"left",否则为"center"|
|
|
20
|
+
|platform|当前所在操作系统,对应不同样式|"ios" \| "android"|跟随当前所在系统|
|
|
21
|
+
|extra|弹窗中的其他元素,比如关闭按钮等|ReactNode|-|
|
|
22
|
+
|contentTransitionType|内容过渡动画类名|string|platform=android 时为"fade",否则为"fade-scale"|
|
|
23
|
+
|maskTransitionTimeout|蒙层动画时长|number \| \{ appear?: number; enter?: number; exit?: number; \}|300|
|
|
24
|
+
|contentTransitionTimeout|弹窗内容动画时长|number \| \{ appear?: number; enter?: number; exit?: number; \}|450|
|
|
25
|
+
|className|自定义类名|string|-|
|
|
26
|
+
|maskClass|自定义蒙层类名|string|-|
|
|
27
|
+
|maskStyle|自定义蒙层样式|CSSProperties|-|
|
|
28
|
+
|contentClass|自定义内容类名|string|-|
|
|
29
|
+
|contentStyle|自定义内容样式|CSSProperties|-|
|
|
30
|
+
|visible|是否展示菜单(受控)|boolean|必填|
|
|
31
|
+
|close|关闭菜单方法|(e: MouseEvent\<HTMLElement, MouseEvent\>) =\> void|必填|
|
|
32
|
+
|maskTransitionType|蒙层过渡动画类名|string|"fade"|
|
|
33
|
+
|contentTransitionVarType|内容过渡动画类名变量标识|string|-|
|
|
34
|
+
|children|菜单内部内容|ReactNode|-|
|
|
35
|
+
|maskClosable|点击蒙层是否关闭菜单|boolean|true|
|
|
36
|
+
|animatingClosable|执行进场动画时点击蒙层是否可关闭菜单|boolean|false|
|
|
37
|
+
|mountOnEnter|是否在打开菜单时再加载内容|boolean|true|
|
|
38
|
+
|unmountOnExit|是否在退出时卸载内容|boolean|true|
|
|
39
|
+
|orientationDirection|transform方向,用于通过transform模拟横屏的情况|"left" \| "right" \| "top" \| "bottom"|"top"|
|
|
40
|
+
|preventBodyScroll|弹窗打开时是否禁止body的滚动|boolean|true|
|
|
41
|
+
|initialBodyOverflow|页面初始 overflow 状态,即关闭弹窗时 overflow 应该还原的状态|string|第一个全屏组件(弹窗、toast等)打开时页面overflow值|
|
|
42
|
+
|gestureOutOfControl|是否禁用滚动容器手势判断,禁用后交给业务方自己判断|boolean|false|
|
|
43
|
+
|onClose|关闭后回调(动画执行完毕)|(scene?: string) =\> void|-|
|
|
44
|
+
|onOpen|打开后回调(动画执行完毕)|() =\> void|-|
|
|
45
|
+
|onMaskClick|点击蒙层回调,maskClosable=false时也会触发|() =\> void|-|
|
|
46
|
+
|onTouchMove|弹窗的touchmove回调|(e: TouchEvent, prevented: boolean, direction: "x" \| "y") =\> void|-|
|
|
47
|
+
|onPreventTouchMove|非滚动区域或滚动到顶部及底部时的触摸事件回调|(e: TouchEvent, direction: "x" \| "y") =\> void|-|
|
|
48
|
+
|getContainer|获取挂载容器|() =\> HTMLElement|-|
|
|
49
|
+
|getScrollContainer|内容内部滚动区域容器,在该容器中未滚动到顶部或底部时会释放滚动|() =\> HTMLElement \| HTMLElement\[\]|-|
|
|
50
|
+
|
|
51
|
+
> 引用/Refs
|
|
52
|
+
|
|
53
|
+
|参数|描述|类型|
|
|
54
|
+
|----------|-------------|------|
|
|
55
|
+
|dom|最外层元素 DOM|HTMLDivElement|
|
|
56
|
+
|mask|蒙层 DOM|HTMLDivElement|
|
|
57
|
+
|content|内容 DOM|HTMLDivElement|
|
|
58
|
+
|setCloseScene|在关闭弹窗前修改 onClose 的 scene 参数值|(scene: string) =\> void|
|
|
59
|
+
|
|
60
|
+
> 方法/Methods
|
|
61
|
+
|
|
62
|
+
|方法名|描述|类型|
|
|
63
|
+
|----------|-------------|------|
|
|
64
|
+
|alert|打开确认框(含一个确认按钮)|(config: AlertOptions & DialogProps) =\> \{ close: () =\> void; update: (newConfig: AlertOptions & DialogProps) =\> void; \}|
|
|
65
|
+
|confirm|打开提示框(含一个确认按钮和一个取消按钮)|(config: ConfirmOptions & AlertOptions) =\> \{ close: () =\> void; update: (newConfig: ConfirmOptions & AlertOptions) =\> void; \}|
|
|
66
|
+
|open|打开常规对话框|(config: DialogProps) =\> \{ close: () =\> void; update: (newConfig: DialogProps) =\> void; \}|
|
|
67
|
+
|
|
68
|
+
> FooterButtonOptions
|
|
69
|
+
|
|
70
|
+
|参数|描述|类型|
|
|
71
|
+
|----------|-------------|------|
|
|
72
|
+
|content|按钮内容|ReactNode \| ((locale: ILocale) =\> ReactNode)|
|
|
73
|
+
|className|按钮类名|string|
|
|
74
|
+
|disabled|是否禁用按钮|boolean|
|
|
75
|
+
|onClick|点击按钮事件,返回值为true时可以阻止dialog关闭|(e: MouseEvent\<HTMLElement, MouseEvent\>) =\> boolean \| void \| Promise\<boolean \| void\>|
|
|
76
|
+
|
|
77
|
+
> ILocale
|
|
78
|
+
|
|
79
|
+
|参数|描述|类型|
|
|
80
|
+
|----------|-------------|------|
|
|
81
|
+
|locale|语言类型|string|
|
|
82
|
+
|LoadMore|-|\{ loadMoreText: string; loadingText: string; noDataText: string; failLoadText: string; prepareScrollText: string; prepareClickText: string; \}|
|
|
83
|
+
|Picker|-|\{ okText: string; cancelText: string; \}|
|
|
84
|
+
|Tag|-|\{ addTag: string; \}|
|
|
85
|
+
|Dialog|-|\{ okText: string; cancelText: string; \}|
|
|
86
|
+
|SwipeLoad|-|\{ normalText: string; activeText: string; \}|
|
|
87
|
+
|PullRefresh|-|\{ loadingText: string; pullingText: string; finishText: string; loosingText: string; \}|
|
|
88
|
+
|DropdownMenu|-|\{ select: string; \}|
|
|
89
|
+
|Pagination|-|\{ previousPage: string; nextPage: string; \}|
|
|
90
|
+
|Image|-|\{ loadError: string; \}|
|
|
91
|
+
|ImagePicker|-|\{ loadError: string; \}|
|
|
92
|
+
|SearchBar|-|\{ placeholder: string; cancelBtn: string; \}|
|
|
93
|
+
|Stepper|-|\{ minusButtonName: string; addButtonName: string; \}|
|
|
94
|
+
|Keyboard|-|\{ confirm: string; \}|
|
|
95
|
+
|Form|-|\{ required: string; type: \{ email: string; url: string; string: string; number: string; array: string; object: string; boolean: string; \}; number: \{ min: string; max: string; equal: string; range: string; positive: string; negative: string; \}; \.\.\. 4 more \.\.\.; pickerDefaultHint: string; \}|
|
|
96
|
+
|NavBar|-|\{ backBtnAriaLabel: string; \}|
|
|
97
|
+
|Uploader|-|\{ uploadBtn: string; retryUpload: string; \}|
|
|
98
|
+
|
|
99
|
+
> AlertOptions
|
|
100
|
+
|
|
101
|
+
|参数|描述|类型|默认值|
|
|
102
|
+
|----------|-------------|------|------|
|
|
103
|
+
|key|组件挂载容器id区分|string|-|
|
|
104
|
+
|onOk|点击确认按钮回调|(e: MouseEvent\<HTMLElement, MouseEvent\>) =\> boolean \| void \| Promise\<boolean \| void\>|-|
|
|
105
|
+
|okText|确认按钮文字|ReactNode|-|
|
|
106
|
+
|unmountOnExit|是否在退出时卸载内容|boolean|true|
|
|
107
|
+
|getContainer|获取挂载容器|() =\> HTMLElement|-|
|
|
108
|
+
|onClose|关闭后回调(动画执行完毕)|(scene?: string) =\> void|-|
|
|
109
|
+
|title|弹窗标题|ReactNode|-|
|
|
110
|
+
|footer|底部按钮配置|FooterButtonOptions\[\]|[]|
|
|
111
|
+
|footerType|底部按钮样式,grid表示通栏样式,button表示按钮样式,platform=ios时有效|"grid" \| "button"|"grid"|
|
|
112
|
+
|renderFooter|自定义渲染footer|() =\> ReactNode|-|
|
|
113
|
+
|footerCollapseCount|底部按钮大于等于多少个时竖向排布|number|3|
|
|
114
|
+
|titleAlign|标题对齐方向|"left" \| "center" \| "right"|platform=android 时为"left",否则为"center"|
|
|
115
|
+
|contentAlign|内容对齐方向|"left" \| "center" \| "right"|platform=android 时为"left",否则为"center"|
|
|
116
|
+
|platform|当前所在操作系统,对应不同样式|"ios" \| "android"|跟随当前所在系统|
|
|
117
|
+
|extra|弹窗中的其他元素,比如关闭按钮等|ReactNode|-|
|
|
118
|
+
|contentTransitionType|内容过渡动画类名|string|platform=android 时为"fade",否则为"fade-scale"|
|
|
119
|
+
|maskTransitionTimeout|蒙层动画时长|number \| \{ appear?: number; enter?: number; exit?: number; \}|300|
|
|
120
|
+
|contentTransitionTimeout|弹窗内容动画时长|number \| \{ appear?: number; enter?: number; exit?: number; \}|450|
|
|
121
|
+
|className|自定义类名|string|-|
|
|
122
|
+
|maskClass|自定义蒙层类名|string|-|
|
|
123
|
+
|maskStyle|自定义蒙层样式|CSSProperties|-|
|
|
124
|
+
|contentClass|自定义内容类名|string|-|
|
|
125
|
+
|contentStyle|自定义内容样式|CSSProperties|-|
|
|
126
|
+
|maskTransitionType|蒙层过渡动画类名|string|"fade"|
|
|
127
|
+
|contentTransitionVarType|内容过渡动画类名变量标识|string|-|
|
|
128
|
+
|children|菜单内部内容|ReactNode|-|
|
|
129
|
+
|maskClosable|点击蒙层是否关闭菜单|boolean|true|
|
|
130
|
+
|animatingClosable|执行进场动画时点击蒙层是否可关闭菜单|boolean|false|
|
|
131
|
+
|mountOnEnter|是否在打开菜单时再加载内容|boolean|true|
|
|
132
|
+
|orientationDirection|transform方向,用于通过transform模拟横屏的情况|"left" \| "right" \| "top" \| "bottom"|"top"|
|
|
133
|
+
|preventBodyScroll|弹窗打开时是否禁止body的滚动|boolean|true|
|
|
134
|
+
|initialBodyOverflow|页面初始 overflow 状态,即关闭弹窗时 overflow 应该还原的状态|string|第一个全屏组件(弹窗、toast等)打开时页面overflow值|
|
|
135
|
+
|gestureOutOfControl|是否禁用滚动容器手势判断,禁用后交给业务方自己判断|boolean|false|
|
|
136
|
+
|onOpen|打开后回调(动画执行完毕)|() =\> void|-|
|
|
137
|
+
|onMaskClick|点击蒙层回调,maskClosable=false时也会触发|() =\> void|-|
|
|
138
|
+
|onTouchMove|弹窗的touchmove回调|(e: TouchEvent, prevented: boolean, direction: "x" \| "y") =\> void|-|
|
|
139
|
+
|onPreventTouchMove|非滚动区域或滚动到顶部及底部时的触摸事件回调|(e: TouchEvent, direction: "x" \| "y") =\> void|-|
|
|
140
|
+
|getScrollContainer|内容内部滚动区域容器,在该容器中未滚动到顶部或底部时会释放滚动|() =\> HTMLElement \| HTMLElement\[\]|-|
|
|
141
|
+
|
|
142
|
+
> GlobalContextParams
|
|
143
|
+
|
|
144
|
+
|参数|描述|类型|默认值|
|
|
145
|
+
|----------|-------------|------|------|
|
|
146
|
+
|prefixCls|组件类名前缀|string|"arco"|
|
|
147
|
+
|system|手动控制当前所在系统,传入后将直接使用传入的值,ssr场景需指定系统初始值时适用|"" \| "ios" \| "android" \| "pc"|""|
|
|
148
|
+
|useDarkMode|是否监听系统原生的暗黑模式变化(prefers\-color\-scheme: dark)以判断是否切为暗黑模式|boolean|false|
|
|
149
|
+
|isDarkMode|是否处于暗黑模式,指定后以指定的值为准|boolean|false|
|
|
150
|
+
|darkModeSelector|当处于暗黑模式时,body上挂载的类名,为空值时不挂载类名|string|"arco-theme-dark"|
|
|
151
|
+
|theme|主题变量,传入后将在线替换css变量,需设置less变量 @use\-css\-vars: 1|Record\<string, string\>|-|
|
|
152
|
+
|locale|国际化语言包配置|ILocale|-|
|
|
153
|
+
|useRtl|是否使用Rtl模式|boolean|false|
|
|
154
|
+
|onDarkModeChange|当系统原生暗黑模式发生变化时触发,useDarkMode=true 时有效|(isDark: boolean) =\> void|-|
|
|
155
|
+
|createRoot|React19 修改了 createRoot 的引入路径,导致组件内部无法直接引入(低react版本会找不到模块)。因此使用 react 19 的用户需从外部传入 createRoot 方法|CreateRootFnType|-|
|
|
156
|
+
|
|
157
|
+
> ConfirmOptions
|
|
158
|
+
|
|
159
|
+
|参数|描述|类型|默认值|
|
|
160
|
+
|----------|-------------|------|------|
|
|
161
|
+
|onCancel|点击取消按钮回调|(e: MouseEvent\<HTMLElement, MouseEvent\>) =\> boolean \| void \| Promise\<boolean \| void\>|-|
|
|
162
|
+
|cancelText|取消按钮文字|ReactNode|-|
|
|
163
|
+
|key|组件挂载容器id区分|string|-|
|
|
164
|
+
|onOk|点击确认按钮回调|(e: MouseEvent\<HTMLElement, MouseEvent\>) =\> boolean \| void \| Promise\<boolean \| void\>|-|
|
|
165
|
+
|okText|确认按钮文字|ReactNode|-|
|
|
166
|
+
|unmountOnExit|是否在退出时卸载内容|boolean|true|
|
|
167
|
+
|getContainer|获取挂载容器|() =\> HTMLElement|-|
|
|
168
|
+
|onClose|关闭后回调(动画执行完毕)|(scene?: string) =\> void|-|
|
|
169
|
+
|title|弹窗标题|ReactNode|-|
|
|
170
|
+
|footer|底部按钮配置|FooterButtonOptions\[\]|[]|
|
|
171
|
+
|footerType|底部按钮样式,grid表示通栏样式,button表示按钮样式,platform=ios时有效|"grid" \| "button"|"grid"|
|
|
172
|
+
|renderFooter|自定义渲染footer|() =\> ReactNode|-|
|
|
173
|
+
|footerCollapseCount|底部按钮大于等于多少个时竖向排布|number|3|
|
|
174
|
+
|titleAlign|标题对齐方向|"left" \| "center" \| "right"|platform=android 时为"left",否则为"center"|
|
|
175
|
+
|contentAlign|内容对齐方向|"left" \| "center" \| "right"|platform=android 时为"left",否则为"center"|
|
|
176
|
+
|platform|当前所在操作系统,对应不同样式|"ios" \| "android"|跟随当前所在系统|
|
|
177
|
+
|extra|弹窗中的其他元素,比如关闭按钮等|ReactNode|-|
|
|
178
|
+
|contentTransitionType|内容过渡动画类名|string|platform=android 时为"fade",否则为"fade-scale"|
|
|
179
|
+
|maskTransitionTimeout|蒙层动画时长|number \| \{ appear?: number; enter?: number; exit?: number; \}|300|
|
|
180
|
+
|contentTransitionTimeout|弹窗内容动画时长|number \| \{ appear?: number; enter?: number; exit?: number; \}|450|
|
|
181
|
+
|className|自定义类名|string|-|
|
|
182
|
+
|maskClass|自定义蒙层类名|string|-|
|
|
183
|
+
|maskStyle|自定义蒙层样式|CSSProperties|-|
|
|
184
|
+
|contentClass|自定义内容类名|string|-|
|
|
185
|
+
|contentStyle|自定义内容样式|CSSProperties|-|
|
|
186
|
+
|maskTransitionType|蒙层过渡动画类名|string|"fade"|
|
|
187
|
+
|contentTransitionVarType|内容过渡动画类名变量标识|string|-|
|
|
188
|
+
|children|菜单内部内容|ReactNode|-|
|
|
189
|
+
|maskClosable|点击蒙层是否关闭菜单|boolean|true|
|
|
190
|
+
|animatingClosable|执行进场动画时点击蒙层是否可关闭菜单|boolean|false|
|
|
191
|
+
|mountOnEnter|是否在打开菜单时再加载内容|boolean|true|
|
|
192
|
+
|orientationDirection|transform方向,用于通过transform模拟横屏的情况|"left" \| "right" \| "top" \| "bottom"|"top"|
|
|
193
|
+
|preventBodyScroll|弹窗打开时是否禁止body的滚动|boolean|true|
|
|
194
|
+
|initialBodyOverflow|页面初始 overflow 状态,即关闭弹窗时 overflow 应该还原的状态|string|第一个全屏组件(弹窗、toast等)打开时页面overflow值|
|
|
195
|
+
|gestureOutOfControl|是否禁用滚动容器手势判断,禁用后交给业务方自己判断|boolean|false|
|
|
196
|
+
|onOpen|打开后回调(动画执行完毕)|() =\> void|-|
|
|
197
|
+
|onMaskClick|点击蒙层回调,maskClosable=false时也会触发|() =\> void|-|
|
|
198
|
+
|onTouchMove|弹窗的touchmove回调|(e: TouchEvent, prevented: boolean, direction: "x" \| "y") =\> void|-|
|
|
199
|
+
|onPreventTouchMove|非滚动区域或滚动到顶部及底部时的触摸事件回调|(e: TouchEvent, direction: "x" \| "y") =\> void|-|
|
|
200
|
+
|getScrollContainer|内容内部滚动区域容器,在该容器中未滚动到顶部或底部时会释放滚动|() =\> HTMLElement \| HTMLElement\[\]|-|
|
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
import type { Ref, ReactNode } from 'react';
|
|
2
|
+
import React, { forwardRef, useImperativeHandle, useRef } from 'react';
|
|
3
|
+
import type { ILocale } from '@arco-design/mobile-utils';
|
|
4
|
+
import { cls, componentWrapper } from '@arco-design/mobile-utils';
|
|
5
|
+
import type { Promise } from 'es6-promise';
|
|
6
|
+
import { ContextLayout, CompWithGlobalContext } from '../context-provider';
|
|
7
|
+
import type { MaskingCommonProps, MaskingRef, OpenBaseProps } from '../masking';
|
|
8
|
+
import Masking from '../masking';
|
|
9
|
+
import { alert, confirm, open } from './methods';
|
|
10
|
+
import { useSystem } from '../_helpers';
|
|
11
|
+
|
|
12
|
+
export * from './methods';
|
|
13
|
+
|
|
14
|
+
export interface FooterButtonOptions {
|
|
15
|
+
/**
|
|
16
|
+
* 按钮内容
|
|
17
|
+
* @en Button content
|
|
18
|
+
*/
|
|
19
|
+
content: ReactNode | ((locale: ILocale) => ReactNode);
|
|
20
|
+
/**
|
|
21
|
+
* 按钮类名
|
|
22
|
+
* @en Button classname
|
|
23
|
+
* */
|
|
24
|
+
className?: string;
|
|
25
|
+
/**
|
|
26
|
+
* 是否禁用按钮
|
|
27
|
+
* @en Whether to disable button
|
|
28
|
+
* */
|
|
29
|
+
disabled?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* 点击按钮事件,返回值为true时可以阻止dialog关闭
|
|
32
|
+
* @en Button clicking event, when the return value is true, the dialog can be prevented from closing
|
|
33
|
+
* */
|
|
34
|
+
onClick?: (
|
|
35
|
+
e: React.MouseEvent<HTMLElement, MouseEvent>,
|
|
36
|
+
) => (void | boolean) | Promise<void | boolean>;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface DialogProps extends MaskingCommonProps {
|
|
40
|
+
/**
|
|
41
|
+
* 弹窗标题
|
|
42
|
+
* @en Dialog title
|
|
43
|
+
* */
|
|
44
|
+
title?: ReactNode;
|
|
45
|
+
/**
|
|
46
|
+
* 底部按钮配置
|
|
47
|
+
* @en Bottom button configuration
|
|
48
|
+
* @default []
|
|
49
|
+
*/
|
|
50
|
+
footer?: FooterButtonOptions[];
|
|
51
|
+
/**
|
|
52
|
+
* 底部按钮样式,grid表示通栏样式,button表示按钮样式,platform=ios时有效
|
|
53
|
+
* @en Bottom button style, grid indicates the banner style, button indicates the button style, valid when platform = ios
|
|
54
|
+
* @default "grid"
|
|
55
|
+
*/
|
|
56
|
+
footerType?: 'grid' | 'button';
|
|
57
|
+
/**
|
|
58
|
+
* 自定义渲染footer
|
|
59
|
+
* @en Custom rendering footer
|
|
60
|
+
* */
|
|
61
|
+
renderFooter?: () => ReactNode;
|
|
62
|
+
/**
|
|
63
|
+
* 底部按钮大于等于多少个时竖向排布
|
|
64
|
+
* @en Vertical arrangement when the number of buttons at the bottom is greater than or equal to the set value
|
|
65
|
+
* @default 3
|
|
66
|
+
*/
|
|
67
|
+
footerCollapseCount?: number;
|
|
68
|
+
/**
|
|
69
|
+
* 标题对齐方向
|
|
70
|
+
* @en Title alignment
|
|
71
|
+
* @default platform=android 时为"left",否则为"center"
|
|
72
|
+
* @default_en "left" when platform=android, "center" otherwise
|
|
73
|
+
*/
|
|
74
|
+
titleAlign?: 'left' | 'center' | 'right';
|
|
75
|
+
/**
|
|
76
|
+
* 内容对齐方向
|
|
77
|
+
* @en Content alignment
|
|
78
|
+
* @default platform=android 时为"left",否则为"center"
|
|
79
|
+
* @default_en "left" when platform=android, "center" otherwise
|
|
80
|
+
*/
|
|
81
|
+
contentAlign?: 'left' | 'center' | 'right';
|
|
82
|
+
/**
|
|
83
|
+
* 当前所在操作系统,对应不同样式
|
|
84
|
+
* @en The current operating system, corresponding to different styles
|
|
85
|
+
* @default 跟随当前所在系统
|
|
86
|
+
* @default_en Follow the system
|
|
87
|
+
*/
|
|
88
|
+
platform?: 'ios' | 'android';
|
|
89
|
+
/**
|
|
90
|
+
* 弹窗中的其他元素,比如关闭按钮等
|
|
91
|
+
* @en Other elements in the dialog, such as the close button, etc.
|
|
92
|
+
* */
|
|
93
|
+
extra?: ReactNode;
|
|
94
|
+
/**
|
|
95
|
+
* 内容过渡动画类名
|
|
96
|
+
* @en Content transition animation classname
|
|
97
|
+
* @default platform=android 时为"fade",否则为"fade-scale"
|
|
98
|
+
* @default_en "fade" when platform=android, "fade-scale" otherwise
|
|
99
|
+
*/
|
|
100
|
+
contentTransitionType?: MaskingCommonProps['contentTransitionType'];
|
|
101
|
+
/**
|
|
102
|
+
* 蒙层动画时长
|
|
103
|
+
* @en Mask animation duration
|
|
104
|
+
* @default 300
|
|
105
|
+
*/
|
|
106
|
+
maskTransitionTimeout?: MaskingCommonProps['maskTransitionTimeout'];
|
|
107
|
+
/**
|
|
108
|
+
* 弹窗内容动画时长
|
|
109
|
+
* @en Dialog content animation duration
|
|
110
|
+
* @default 450
|
|
111
|
+
*/
|
|
112
|
+
contentTransitionTimeout?: MaskingCommonProps['contentTransitionTimeout'];
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export interface DialogRef extends MaskingRef {}
|
|
116
|
+
|
|
117
|
+
const Dialog = forwardRef((props: DialogProps, ref: Ref<DialogRef>) => {
|
|
118
|
+
const system = useSystem();
|
|
119
|
+
const nowSystem = props.platform || system;
|
|
120
|
+
const {
|
|
121
|
+
close = () => {},
|
|
122
|
+
children,
|
|
123
|
+
title,
|
|
124
|
+
footer = [],
|
|
125
|
+
footerType = 'grid',
|
|
126
|
+
renderFooter,
|
|
127
|
+
footerCollapseCount = 3,
|
|
128
|
+
titleAlign = nowSystem === 'android' ? 'left' : 'center',
|
|
129
|
+
contentAlign = nowSystem === 'android' ? 'left' : 'center',
|
|
130
|
+
className,
|
|
131
|
+
maskClass,
|
|
132
|
+
contentClass,
|
|
133
|
+
contentStyle,
|
|
134
|
+
contentTransitionType = nowSystem === 'android' ? 'fade' : 'fade-scale',
|
|
135
|
+
maskTransitionTimeout = 300,
|
|
136
|
+
contentTransitionTimeout = nowSystem === 'android' ? 300 : { enter: 450, exit: 150 },
|
|
137
|
+
extra,
|
|
138
|
+
...restProps
|
|
139
|
+
} = props;
|
|
140
|
+
const maskingRef = useRef<MaskingRef>(null);
|
|
141
|
+
const contentRef = useRef<HTMLDivElement>(null);
|
|
142
|
+
|
|
143
|
+
useImperativeHandle(ref, () => ({
|
|
144
|
+
dom: maskingRef.current?.dom || null,
|
|
145
|
+
mask: maskingRef.current?.mask || null,
|
|
146
|
+
content: contentRef.current,
|
|
147
|
+
setCloseScene: maskingRef.current?.setCloseScene || (() => {}),
|
|
148
|
+
}));
|
|
149
|
+
|
|
150
|
+
function handleFooterBtnClick(
|
|
151
|
+
e: React.MouseEvent<HTMLElement, MouseEvent>,
|
|
152
|
+
btn: FooterButtonOptions,
|
|
153
|
+
) {
|
|
154
|
+
e.preventDefault();
|
|
155
|
+
e.stopPropagation();
|
|
156
|
+
if (btn.disabled) {
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
const result = btn.onClick ? btn.onClick(e) : null;
|
|
160
|
+
if (!result || typeof result === 'boolean') {
|
|
161
|
+
!result && close(e);
|
|
162
|
+
} else if (result && result.then) {
|
|
163
|
+
result.then(res => !res && close(e));
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function renderDialog({ prefixCls, locale }) {
|
|
168
|
+
const prefix = `${prefixCls}-dialog`;
|
|
169
|
+
return (
|
|
170
|
+
<Masking
|
|
171
|
+
close={close}
|
|
172
|
+
className={cls(prefix, nowSystem, className)}
|
|
173
|
+
ref={maskingRef}
|
|
174
|
+
maskClass={cls(`${prefix}-mask`, maskClass)}
|
|
175
|
+
contentTransitionType={contentTransitionType}
|
|
176
|
+
contentClass={cls(`${prefix}-container`)}
|
|
177
|
+
maskTransitionTimeout={maskTransitionTimeout}
|
|
178
|
+
contentTransitionTimeout={contentTransitionTimeout}
|
|
179
|
+
{...restProps}
|
|
180
|
+
>
|
|
181
|
+
<div
|
|
182
|
+
className={cls(`${prefix}-content`, `${prefix}-part`, nowSystem, contentClass)}
|
|
183
|
+
style={contentStyle}
|
|
184
|
+
ref={contentRef}
|
|
185
|
+
>
|
|
186
|
+
{title ? (
|
|
187
|
+
<div
|
|
188
|
+
className={cls(
|
|
189
|
+
`${prefix}-header`,
|
|
190
|
+
`${prefix}-part`,
|
|
191
|
+
titleAlign,
|
|
192
|
+
nowSystem,
|
|
193
|
+
`system-${system}`,
|
|
194
|
+
{ 'only-title': !children },
|
|
195
|
+
)}
|
|
196
|
+
>
|
|
197
|
+
{title}
|
|
198
|
+
</div>
|
|
199
|
+
) : null}
|
|
200
|
+
{children ? (
|
|
201
|
+
<div
|
|
202
|
+
className={cls(
|
|
203
|
+
`${prefix}-body`,
|
|
204
|
+
`${prefix}-part`,
|
|
205
|
+
contentAlign,
|
|
206
|
+
nowSystem,
|
|
207
|
+
{
|
|
208
|
+
'sub-title': !title,
|
|
209
|
+
},
|
|
210
|
+
)}
|
|
211
|
+
>
|
|
212
|
+
{children}
|
|
213
|
+
</div>
|
|
214
|
+
) : null}
|
|
215
|
+
{renderFooter || footer.length ? (
|
|
216
|
+
<div
|
|
217
|
+
className={cls(
|
|
218
|
+
`${prefix}-footer`,
|
|
219
|
+
`${prefix}-part`,
|
|
220
|
+
nowSystem,
|
|
221
|
+
`type-${footerType}`,
|
|
222
|
+
{
|
|
223
|
+
collapsed: footer.length >= footerCollapseCount,
|
|
224
|
+
},
|
|
225
|
+
)}
|
|
226
|
+
>
|
|
227
|
+
{renderFooter
|
|
228
|
+
? renderFooter()
|
|
229
|
+
: footer.map((btn, index) => (
|
|
230
|
+
<div
|
|
231
|
+
key={index}
|
|
232
|
+
className={cls(
|
|
233
|
+
'dialog-footer-button',
|
|
234
|
+
btn.className,
|
|
235
|
+
`system-${system}`,
|
|
236
|
+
{ disabled: btn.disabled },
|
|
237
|
+
)}
|
|
238
|
+
onClick={e => handleFooterBtnClick(e, btn)}
|
|
239
|
+
>
|
|
240
|
+
{typeof btn.content === 'function'
|
|
241
|
+
? btn.content(locale)
|
|
242
|
+
: btn.content}
|
|
243
|
+
</div>
|
|
244
|
+
))}
|
|
245
|
+
</div>
|
|
246
|
+
) : null}
|
|
247
|
+
{/* 往后追加div元素会使.${prefix}-part:last-of-type失效,因此包裹span元素 */}
|
|
248
|
+
{/* Appending the div element afterward will invalidate .${prefix}-part:last-of-type, thus wrapping the span element */}
|
|
249
|
+
{extra ? <section>{extra}</section> : null}
|
|
250
|
+
</div>
|
|
251
|
+
</Masking>
|
|
252
|
+
);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
return <ContextLayout>{renderDialog}</ContextLayout>;
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
export interface AlertOptions extends Omit<DialogProps, 'visible' | 'close'> {
|
|
259
|
+
/**
|
|
260
|
+
* 组件挂载容器id区分
|
|
261
|
+
* @en Component mount container id distinction
|
|
262
|
+
* */
|
|
263
|
+
key?: string;
|
|
264
|
+
/**
|
|
265
|
+
* 点击确认按钮回调
|
|
266
|
+
* @en Callback when clicking OK button
|
|
267
|
+
* */
|
|
268
|
+
onOk?: FooterButtonOptions['onClick'];
|
|
269
|
+
/**
|
|
270
|
+
* 确认按钮文字
|
|
271
|
+
* @en Ok button text
|
|
272
|
+
* */
|
|
273
|
+
okText?: ReactNode;
|
|
274
|
+
}
|
|
275
|
+
export interface ConfirmOptions extends AlertOptions {
|
|
276
|
+
/**
|
|
277
|
+
* 点击取消按钮回调
|
|
278
|
+
* @en Callback when clicking cancel button
|
|
279
|
+
* */
|
|
280
|
+
onCancel?: FooterButtonOptions['onClick'];
|
|
281
|
+
/**
|
|
282
|
+
* 取消按钮文字
|
|
283
|
+
* @en Cancel button text
|
|
284
|
+
* */
|
|
285
|
+
cancelText?: ReactNode;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
export function methodsGenerator<
|
|
289
|
+
P extends OpenBaseProps,
|
|
290
|
+
A extends { key?: string } = AlertOptions,
|
|
291
|
+
C extends { key?: string } = ConfirmOptions,
|
|
292
|
+
>(Comp: React.FunctionComponent<P>) {
|
|
293
|
+
return {
|
|
294
|
+
/**
|
|
295
|
+
* 打开确认框(含一个确认按钮)
|
|
296
|
+
* @desc {en} Open a confirmation dialog (with a confirmation button)
|
|
297
|
+
* @param {AlertOptions & DialogProps} config Configuration
|
|
298
|
+
* @returns {{ close: () => void; update: (newConfig: AlertOptions & DialogProps) => void; }}
|
|
299
|
+
*/
|
|
300
|
+
alert: alert<A, P>(Comp),
|
|
301
|
+
/**
|
|
302
|
+
* 打开提示框(含一个确认按钮和一个取消按钮)
|
|
303
|
+
* @desc {en} Open a prompt dialog (with a confirm button and a cancel button)
|
|
304
|
+
* @param {ConfirmOptions & AlertOptions} config Configuration
|
|
305
|
+
* @returns {{ close: () => void; update: (newConfig: ConfirmOptions & AlertOptions) => void; }}
|
|
306
|
+
*/
|
|
307
|
+
confirm: confirm<C, P>(Comp),
|
|
308
|
+
/**
|
|
309
|
+
* 打开常规对话框
|
|
310
|
+
* @desc {en} Open the general dialog
|
|
311
|
+
* @param {DialogProps} config Configuration
|
|
312
|
+
* @returns {{ close: () => void; update: (newConfig: DialogProps) => void; }}
|
|
313
|
+
*/
|
|
314
|
+
open: open(Comp),
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
const DialogWithGlobalContext = CompWithGlobalContext(Dialog);
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* 模态对话框,在浮层中显示,引导用户进行相关操作。默认做了防滚动穿透处理,如果弹层内容中需要滚动,则需将滚动容器传入`getScrollContainer`属性以在未滚动到顶部或底部时释放滚动。
|
|
322
|
+
* @en A modal dialog, displayed in a floating layer, guides the user to perform related operations. By default, anti-scroll penetration processing is performed. If scrolling is required in the content of the bullet layer, you need to pass the scroll container to `getScrollContainer` to release scrolling when it is not scrolled to the top or bottom.
|
|
323
|
+
* @type 反馈
|
|
324
|
+
* @type_en FeedBack
|
|
325
|
+
* @name 对话框
|
|
326
|
+
* @name_en Dialog
|
|
327
|
+
*/
|
|
328
|
+
export default componentWrapper(Dialog, methodsGenerator(DialogWithGlobalContext));
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ILocale } from '@arco-design/mobile-utils';
|
|
3
|
+
import { getOpenMethod, open as maskingOpen, OpenBaseProps } from '../masking/methods';
|
|
4
|
+
|
|
5
|
+
export function normalizeAlert<AlertOptions, P>(config: AlertOptions): P {
|
|
6
|
+
const { onOk, okText, ...restConfig } = config || ({} as any);
|
|
7
|
+
return {
|
|
8
|
+
footer: [
|
|
9
|
+
{
|
|
10
|
+
content: okText || ((locale: ILocale) => locale.Dialog.okText),
|
|
11
|
+
className: 'confirm',
|
|
12
|
+
onClick: onOk,
|
|
13
|
+
},
|
|
14
|
+
],
|
|
15
|
+
...restConfig,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function normalizeConfirm<ConfirmOptions, P>(config: ConfirmOptions): P {
|
|
20
|
+
const { onOk, okText, onCancel, cancelText, ...restConfig } = config || ({} as any);
|
|
21
|
+
return {
|
|
22
|
+
footer: [
|
|
23
|
+
{
|
|
24
|
+
content: cancelText || ((locale: ILocale) => locale.Dialog.cancelText),
|
|
25
|
+
className: 'cancel',
|
|
26
|
+
onClick: onCancel,
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
content: okText || ((locale: ILocale) => locale.Dialog.okText),
|
|
30
|
+
className: 'confirm',
|
|
31
|
+
onClick: onOk,
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
...restConfig,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const dialogId = 'ARCO_DIALOG';
|
|
39
|
+
|
|
40
|
+
export function alert<AlertOptions extends { key?: string }, P extends OpenBaseProps>(
|
|
41
|
+
Component: React.FunctionComponent<P>,
|
|
42
|
+
normalize?: <T, Props>(config: T) => Props,
|
|
43
|
+
) {
|
|
44
|
+
return getOpenMethod<AlertOptions, P>(Component, dialogId, normalize || normalizeAlert);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function confirm<ConfirmOptions extends { key?: string }, P extends OpenBaseProps>(
|
|
48
|
+
Component: React.FunctionComponent<P>,
|
|
49
|
+
normalize?: <T, Props>(config: T) => Props,
|
|
50
|
+
) {
|
|
51
|
+
return getOpenMethod<ConfirmOptions, P>(Component, dialogId, normalize || normalizeConfirm);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function open<P extends OpenBaseProps>(Component: React.FunctionComponent<P>) {
|
|
55
|
+
return maskingOpen(Component, dialogId);
|
|
56
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
### 布局
|
|
2
|
+
|
|
3
|
+
# 分割线 Divider
|
|
4
|
+
|
|
5
|
+
划分内容的装饰线
|
|
6
|
+
|
|
7
|
+
======
|
|
8
|
+
|
|
9
|
+
> 属性/Props
|
|
10
|
+
|
|
11
|
+
|参数|描述|类型|默认值|
|
|
12
|
+
|----------|-------------|------|------|
|
|
13
|
+
|hairline|是否使用 0\.5px 线|boolean|true|
|
|
14
|
+
|content|文字|ReactNode|-|
|
|
15
|
+
|align|文字位置|"left" \| "center" \| "right"|'center'|
|
|
16
|
+
|width|分割线宽度(单边),仅在\`align\`为\`center\`时生效|ReactText|-|
|
|
17
|
+
|children|子元素,同 content,优先级低于 content|ReactNode|null|
|
|
18
|
+
|className|自定义类名|string|""|
|
|
19
|
+
|style|自定义样式|CSSProperties|{}|
|
|
20
|
+
|
|
21
|
+
> 引用/Refs
|
|
22
|
+
|
|
23
|
+
|参数|描述|类型|
|
|
24
|
+
|----------|-------------|------|
|
|
25
|
+
|dom|最外层 DOM 元素|HTMLDivElement|
|