1+ import classNames from 'classnames'
2+ import type { CSSProperties , FC , ReactNode } from 'react'
13import React from 'react'
2- import type { FC , ReactNode , CSSProperties } from 'react'
34import { NativeProps , withNativeProps } from '../../utils/native-props'
5+ import { renderImperatively } from '../../utils/render-imperatively'
46import { mergeProps } from '../../utils/with-default-props'
5- import classNames from 'classnames '
7+ import { useConfig } from '../config-provider '
68import Popup , { PopupProps } from '../popup'
79import SafeArea from '../safe-area'
8- import { renderImperatively } from '../../utils/render-imperatively'
9-
10- const classPrefix = `adm-action-sheet`
1110
1211export type Action = {
1312 key : string | number
@@ -34,6 +33,7 @@ export type ActionSheetProps = {
3433 /** @deprecated use `styles` instead */
3534 popupStyle ?: CSSProperties
3635 styles ?: Partial < Record < 'body' | 'mask' , CSSProperties > >
36+ prefixCls ?: string
3737} & Pick <
3838 PopupProps ,
3939 'afterClose' | 'getContainer' | 'destroyOnClose' | 'forceRender'
@@ -53,8 +53,9 @@ const defaultProps = {
5353
5454export const ActionSheet : FC < ActionSheetProps > = p => {
5555 const props = mergeProps ( defaultProps , p )
56+ const { getPrefixCls } = useConfig ( )
5657 const { styles } = props
57-
58+ const prefixCls = getPrefixCls ( 'action-sheet' , props . prefixCls )
5859 return (
5960 < Popup
6061 visible = { props . visible }
@@ -65,7 +66,7 @@ export const ActionSheet: FC<ActionSheetProps> = p => {
6566 }
6667 } }
6768 afterClose = { props . afterClose }
68- className = { classNames ( `${ classPrefix } -popup` , props . popupClassName ) }
69+ className = { classNames ( `${ prefixCls } -popup` , props . popupClassName ) }
6970 style = { props . popupStyle }
7071 getContainer = { props . getContainer }
7172 destroyOnClose = { props . destroyOnClose }
@@ -75,24 +76,24 @@ export const ActionSheet: FC<ActionSheetProps> = p => {
7576 >
7677 { withNativeProps (
7778 props ,
78- < div className = { classPrefix } >
79+ < div className = { prefixCls } >
7980 { props . extra && (
80- < div className = { `${ classPrefix } -extra` } > { props . extra } </ div >
81+ < div className = { `${ prefixCls } -extra` } > { props . extra } </ div >
8182 ) }
82- < div className = { `${ classPrefix } -button-list` } >
83+ < div className = { `${ prefixCls } -button-list` } >
8384 { props . actions . map ( ( action , index ) => (
8485 < div
8586 key = { action . key }
86- className = { `${ classPrefix } -button-item-wrapper` }
87+ className = { `${ prefixCls } -button-item-wrapper` }
8788 >
8889 < a
8990 className = { classNames (
9091 'adm-plain-anchor' ,
91- `${ classPrefix } -button-item` ,
92+ `${ prefixCls } -button-item` ,
9293 {
93- [ `${ classPrefix } -button-item-danger` ] : action . danger ,
94- [ `${ classPrefix } -button-item-disabled` ] : action . disabled ,
95- [ `${ classPrefix } -button-item-bold` ] : action . bold ,
94+ [ `${ prefixCls } -button-item-danger` ] : action . danger ,
95+ [ `${ prefixCls } -button-item-disabled` ] : action . disabled ,
96+ [ `${ prefixCls } -button-item-bold` ] : action . bold ,
9697 }
9798 ) }
9899 onClick = { ( ) => {
@@ -105,11 +106,11 @@ export const ActionSheet: FC<ActionSheetProps> = p => {
105106 role = 'option'
106107 aria-disabled = { action . disabled }
107108 >
108- < div className = { `${ classPrefix } -button-item-name` } >
109+ < div className = { `${ prefixCls } -button-item-name` } >
109110 { action . text }
110111 </ div >
111112 { action . description && (
112- < div className = { `${ classPrefix } -button-item-description` } >
113+ < div className = { `${ prefixCls } -button-item-description` } >
113114 { action . description }
114115 </ div >
115116 ) }
@@ -120,19 +121,19 @@ export const ActionSheet: FC<ActionSheetProps> = p => {
120121
121122 { props . cancelText && (
122123 < div
123- className = { `${ classPrefix } -cancel` }
124+ className = { `${ prefixCls } -cancel` }
124125 role = 'option'
125126 aria-label = { props . cancelText }
126127 >
127- < div className = { `${ classPrefix } -button-item-wrapper` } >
128+ < div className = { `${ prefixCls } -button-item-wrapper` } >
128129 < a
129130 className = { classNames (
130131 'adm-plain-anchor' ,
131- `${ classPrefix } -button-item`
132+ `${ prefixCls } -button-item`
132133 ) }
133134 onClick = { props . onClose }
134135 >
135- < div className = { `${ classPrefix } -button-item-name` } >
136+ < div className = { `${ prefixCls } -button-item-name` } >
136137 { props . cancelText }
137138 </ div >
138139 </ a >
0 commit comments